Listing 1

1  Method m = null;
2  try {
3    Class c = PrintStream.class;
4    m = c.getMethod("println", 
         String.class);
5  } catch(NoSuchMethodException e) {
6  }
7  try {
8    m.invoke(System.out, 
         "Hello World!");
9  } catch(IllegalAccessException e) {
10 } catch(InvocationTargetException e){
11 }

Listing 2

1 public static UIListener create(
      Object... params) {
2   return (UIListener)Proxy
        .newProxyInstance(
3     object.getClass()
          .getClassLoader(), 
4     new Class[] { UIListener.class },
5     new UIDelegateProxy(params));
6 }

Listing 3

1  private void checkProgress(
       ActionEvent e) { 
2    if (progress.isDone()) {
3      dialog.dispose();
4      timer.stop();
5      if (completedDelegate != null) {
6        completedDelegate.invoke(
             progress.getCurrent());
7      }
8    } else {
9      noteLabel.setText(
          progress.getNote());
10     progressBar.setValue(
           progress.getCurrent());
11   }
12 }

Listing 4

 1 public interface IProgress {
 2   public void reset();
 3   public int getCurrent();
 4   public boolean isDone();
 5   public String getNote();
 6   public String getLargestNote();
 7   public void requestCancel();
 8   public int getMin();
 9   public int getMax();
10   public Object getResult();
11 }

Additional Code for this article - zip file format