Taking JavaFX Head-on: Java SwingBuilder 0.1.RC2 [UPDATED]
Join the DZone community and get the full member experience.Join For Free
Java SwingBuilder is an attempt to bring dynamic language-type productivity to Java Swing UI development by defining the layout/event wiring/binding in a separate YAML file and leaving the Java class to focus on pure business-side code. Inspired by Groovy SwingBuilder (the concept in general), Ruby on Rails (YAML is the new JSON/XML, but leaner) and GTK+ libGlade (for the idea of keeping layout and event wiring in a separate file). It also pinches a few ideas from Apache Wicket (e.g. keeping the Java and source YAML file in the same package with the same name as a hard-coded convention).
Summary: 0.1 Release Candidate 2 for the Java SwingBuilder project, an alternative approach to declarative UIs in pure Java.
We borrow ideas from the best and throw in a few of our own, such as our DSL for visual layout management, which basically provides you a GUI builder...in pure text (it's like Matisse for Notepad). I think it's the crown jewel of the Java SwingBuilder, nothing like it exists in any other tool (including the Groovy SwingBuilder or the new JRuby Glimmer).
We also provide a simple way to hook up events directly to Java methods without the need to code any listener or wait for closures to arrive. A simple Java annotation is all that is needed to flag a method to be executed in the background using SwingWorker. There is also some initial work done on integrating data input validation using Apache Commons Validators routines.
Uses MigLayout as the main layout manager (supports CardLayout and FlowLayout as well). MigLayout makes all other JDK layout managers obsolete, hence none of them are supported. Data binding is supported via the standard Beans Binding library and support for long running tasks is integrated via SwingWorker.
End goal of the project: to define max functionality with the least amount of code and make JavaFX obsolete before it even arrives. The original idea for the project came out of frustration with Sun's strategy of forcing a whole new language (JavaFX Script) instead of enhancing pure good old Java.
Sample UI, YAML build file and the Java file that loads it:
Please visit the main project site and read up on the Wiki:
or post questions in our Google Group:
Opinions expressed by DZone contributors are their own.