1.1 --- a/examples/Tkinter/Application.java Mon Jan 10 23:41:59 2005 +0100
1.2 +++ b/examples/Tkinter/Application.java Mon Jan 10 23:43:02 2005 +0100
1.3 @@ -1,5 +1,5 @@
1.4 public class Application extends tkjava.Frame {
1.5 - private tkjava.Button quit, hiThere;
1.6 + private tkjava.Button QUIT, hiThere;
1.7
1.8 public Application() {
1.9 super();
1.10 @@ -7,10 +7,31 @@
1.11 this.createWidgets();
1.12 }
1.13
1.14 + public void sayHello() {
1.15 + System.out.println("hi there, everyone!");
1.16 + }
1.17 +
1.18 public void createWidgets() {
1.19 - this.quit = new tkjava.Button(this);
1.20 - this.quit.pack();
1.21 +
1.22 + // Instead of just getting tkjava.Frame.quit or even this.quit...
1.23 +
1.24 + Class[] empty = new Class[0];
1.25 + java.lang.reflect.Method quit = null, sayHello = null;
1.26 + try {
1.27 + quit = this.getClass().getMethod("quit", empty);
1.28 + sayHello = this.getClass().getMethod("sayHello", empty);
1.29 + } catch (NoSuchMethodException exc) {
1.30 + // Methods remain as null -> None and will cause runtime errors.
1.31 + }
1.32 +
1.33 + this.QUIT = new tkjava.Button(this);
1.34 + this.QUIT.__setitem__("text", "QUIT");
1.35 + this.QUIT.__setitem__("fg", "red");
1.36 + this.QUIT.__setitem__("command", quit);
1.37 + this.QUIT.pack();
1.38 this.hiThere = new tkjava.Button(this);
1.39 + this.hiThere.__setitem__("text", "Hello");
1.40 + this.hiThere.__setitem__("command", sayHello);
1.41 this.hiThere.pack();
1.42 }
1.43 }