Chapter 9. Using Swing
Swing is the Java standard GUI toolkit as of Java 1.2. It offers a number of advantages over the Abstract Windowing Toolkit (AWT) that was in use before Swing was developed. Among those advantages are a more complete and powerful widget set, lightweight widgets that are drawn in Java, custom look-and-feel designs, and a more flexible and useful event model. Swing uses the JavaBeans specification heavily—it’s probably the most aggressively “beaned” Java library in existence—to allow Swing components to be easily added to GUI toolkits that allow the programmer to manipulate the interface design via the bean properties. More information on the JavaBean reflection shortcuts used by Jython in this chapter is contained in Bean-Based Reflection in Chapter 8.
If you’ve spent much time programming in Swing, you know two things. First, you know that Swing is very flexible and powerful. Second, you know that it can be verbose, complex, and downright quirky at times. Swing is definitely an area where Jython’s simplification and clarity are particularly useful.
The combination of the Python language, the Jython bean access shortcuts, and Swing is hard to beat as a GUI prototyping kit. If you do prototype your Java GUI in Jython, there is a good chance you’ll find writing Swing in Jython so much easier that you will wind up keeping the Jython and never translating to Java at all. If you have programmed GUIs in CPython, we think you’ll also find that Jython/Swing is an excellent ...
Get Jython Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.