Last updated October 28, 2008 15:28, by Bruce Johnson
= Tk-like GUI Toolkit in Java/Swing Wiki =
[[Changes]] to Swank.
===Development of Swank===
Swing, the Java user interface toolkit, provided a rich variety of widgets with similar functionality to Tk widgets. Using the Swing widgets meant that the behavior of Swank would not be as similar to Tk as it would if the Swank widgets were developed from lower level Java components. On the other hand, adopting Swing meant that a great deal of coding work could be skipped. Furthermore, using the Swing widgets provides a richer set of behaviors than the original Tk widgets.
A key to the development of Swank was the introspection capabilities of the Jacl language. Much of the code that forms the basis of Swank is generated by Jacl scripts that determine the fields and methods of each Swing component and then automatically produce Java code that provides a Tk-like interface to the components. This generates a large number of configuration options for each widget. Some of these map coincidentally to the names and functions of Tk configuration options. In other cases, Jacl code is used to specifically generate Java code for Tk options. In some of these cases it is only necessary to generate code that parses the appropriate Tk option and maps it to an existing Java Swing method. In other cases specific Java code is written to enable the correct action in response to the specified option. This Java code is inserted in the generated Java file. Integer, double, and String arguments are processed with standard Jacl API commands. Other arguments are processed by hand written Java code specific to each argument type.
At present most Tk widgets are im-plemented in Swank and have similar be-havior and implement most of the Tk con-figuration options. The above introspection protocol also generates many additional configuration options for each of the widgets





