Events and bindings

In this section, we'll really start "cooking with gas"! Despite the section title, it's really all about making Java and Tcl work tightly together. We'll look at accessing Java objects by property instead of through methods, binding callback scripts to Java events, and accessing the Tcl interpreter from Java. Our examples will all construct simple Java GUIs from within Tcl.

All of the examples in this section will only run properly in wish.

Why?
Because you need an event loop to allow the GUI to respond to input from graphical widgets. You can make an event loop in tclsh b executing this code after creating all the Java widgets:
  set hangHere 0
  vwait hangHere
The only problem with this is that the interactive console will no longer respond! So this is not so useful for exploration and debugging. Once you have a Java GUI working in wish, though, you can add this code to the bottom of your script and run it in tclsh.