Skip to main content

text2gui 1.0 released - new Swing development tool

2 replies [Last post]
Joined: 2004-09-11

Hi Swing developers,

I'd like to announce my product, called text2gui, which makes Java Swing GUI development extremely easy. With text2gui, you can describe an entire GUI hierarchy with a simple syntax which is much easier to write than Java. You don't need to recompile your application to make changes to the GUI, which saves you a ton of development time. Also, GUI descriptions are stored in resource bundle files, making internationalizing your application simple.

Finally, unlike other GUI builder tools, text2gui allows you to update and receive notifications from your created GUI with simple, uniform mechanisms. This allows you to implement your GUI with the MVC architecture, which leads to cleaner, more maintainable code.

text2gui also includes a GUI editor tool which you can use to edit your GUI descriptions and test them with a single button click.

text2gui is available for purchase by commercial users, but it may be licensed for a nominal fee by free software developers. An evaluation version can also be downloaded for free. Please check it out!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-10

Hi jctsay,

Could you please provide an short example showing text2gui's advantages? Thanks in advance.


Joined: 2004-09-11

Hi Tom,

Thanks for your question, and sorry about the delayed response.

Here is an example that shows off some of text2gui's capabilities. A GUI
description for text2gui is normally stored and edited in a resource bundle
file. Such a bundle, which contains a description of a dialog box that lets
the user select a value, might look like this:

dialog.title=Complex Dialog

{%valueLabel, {north}},
{%valueSpinner, {center}},
{%buttonPanel, {south}}

valueLabel.text=Enter a value:


buttonPanel.layout=box axis=x
%okButton, {strut}, %cancelButton

new ActionListener() {
public void actionPerformed(ActionEvent e) {
argMap.putNoReturn("accepted", Boolean.TRUE);
getGlobal("cdialog", argMap).dispose();

new ActionListener() {
public void actionPerformed(ActionEvent e) {
argMap.putNoReturn("accepted", Boolean.FALSE);
getGlobal("cdialog", argMap).dispose();

The Java code to create the dialog looks like this:

// Create the resource bundle
ResourceBundle bundle = ChainedResourceBundleFactory.getBundle("MyBundle");

// Create the map used to communicate with the GUI
IObservableNoReturnMap argMap = new ObservableMap();

// Set the initial value of the spinner
argMap.put("val", new Integer(40));

// Optional: listen for changes to the spinner
argMap.addPropertyChangeListener("val", new PropertyChangeListener() { ... });

// Finally, create the dialog box
JDialog dialog = DispatchingComponentConverter.DEFAULT_INSTANCE.toComponent(
bundle, "dialog", argMap);


if (Boolean.TRUE.equals(argMap.get("accepted"))) {
// Get the value the user chose
int value = ((Integer) argMap.get("val")).intValue();

// Do something based on the value

That may seem long, but that's the entire code to create the dialog box
including all of its contents. If the contents change, the Java code
doesn't have to. For example, you might want to add a border to the content
panel. You could add the line:

contentPanel.border=titled title="Choose something"

Or perhaps you'd like to change the spinner to a slider:

{%valueLabel, {north}},
{%valueSlider, {center}},
{%buttonPanel, {south}}


Any other change to the contents of dialog box can be done in the same way,
without recompiling the Java code. All you need to do is edit the resource
bundle file and restart the application (it's possible to avoid the restart
as well).

If you wanted to adapt your application for a different language, you would
create a locale specific resource bundle that overloads some keys. For example,
for the Spanish locale, you might have this single line resource bundle:

valueLabel.text=Entre un numero:

Still, there is no need to recompile the Java code.

If you wanted to respond to the value of the slider/spinner as the user changes
it, you would add a property change listener to the argument map.

Notice the Java code is agnostic about how the GUI is implemented, even how
variables are displayed or gathered. This gives you considerable flexibility.
You can even upgrade the GUI after your application is deployed by
distributing a new resource bundle file. Or you might let users create their
own GUI's, like skins but more powerful.

Also notice that code can be embedded in text2gui descriptions: the action
listeners for the OK and Cancel button where written in BeanShell, which is
basically a scripted version of Java (easy to learn, no types). Another way
that GUI's can cause your application's code to be executed is to watch for
changes in the argument map using a property change listener. For example,
the "pressed" property of a button can be listened to, then your application
can respond to it by executing the proper code.

Hope that helps to explain the advantages of text2gui. For more information,
including demos, please visit the web site:

You may also download the evaluation version which has the demos and complete
documentation. Please contact me ( or post a reply) if
you have further questions. Thanks for your interest!

Jeff Tsay