# HG changeset patch # User Paul Boddie # Date 1105396982 -3600 # Node ID ed0c9db3100d428f5dc4a62056d5721ee318c75d # Parent c2b3de28489c345917ddd578abdea3e63f3d97b6 Added button configuration and callbacks. diff -r c2b3de28489c -r ed0c9db3100d examples/Tkinter/Application.java --- a/examples/Tkinter/Application.java Mon Jan 10 23:41:59 2005 +0100 +++ b/examples/Tkinter/Application.java Mon Jan 10 23:43:02 2005 +0100 @@ -1,5 +1,5 @@ public class Application extends tkjava.Frame { - private tkjava.Button quit, hiThere; + private tkjava.Button QUIT, hiThere; public Application() { super(); @@ -7,10 +7,31 @@ this.createWidgets(); } + public void sayHello() { + System.out.println("hi there, everyone!"); + } + public void createWidgets() { - this.quit = new tkjava.Button(this); - this.quit.pack(); + + // Instead of just getting tkjava.Frame.quit or even this.quit... + + Class[] empty = new Class[0]; + java.lang.reflect.Method quit = null, sayHello = null; + try { + quit = this.getClass().getMethod("quit", empty); + sayHello = this.getClass().getMethod("sayHello", empty); + } catch (NoSuchMethodException exc) { + // Methods remain as null -> None and will cause runtime errors. + } + + this.QUIT = new tkjava.Button(this); + this.QUIT.__setitem__("text", "QUIT"); + this.QUIT.__setitem__("fg", "red"); + this.QUIT.__setitem__("command", quit); + this.QUIT.pack(); this.hiThere = new tkjava.Button(this); + this.hiThere.__setitem__("text", "Hello"); + this.hiThere.__setitem__("command", sayHello); this.hiThere.pack(); } }