Java GUI Generation - JGuiGen

Version 4.0

JGuiGen - a Java GUI Generation System
Elegant CRUD
Major Update July 4, 2006

JGuiGen is a java application designed to help developers who work with rich clients and SQL back end databases.

Check out the Screencasts to see what JGuiGen is all about ...

  1. JGuiGen Demo Screencast 13 minutes
    1. This Screencast shows some features your users will get when you generate a GUI using JGuiGen
    2. created on 20060510 using revision 235
    3. the JGuiGenDemo Script
  2. JGuiGen Screencast 14 minutes
    1. In this demo, we show how you can quickly generate a GUI.
    2. created on 20060512 using revision 235
    3. the JGuiGen Lead Script
  3. the JGuiGen Demo in Wiki

The most current version code is available for download using subversion.
The subversion URL is
So you can browse the repository here.
You will need to download a subversion client in order to obtain the source code this way.

The most recent stable version is also available on SourceForge for download as a zip file.
Other links to the source code are also at the bottom of this screen - either through Java Web Start or downloading the full source code.
At this point you will need to send patches/fixes to us. We will be adding other developers based on their interest and expertise.

A simple way to generate a GUI.
  1. Run JGuiGen,
  2. Click on CREATE,
  3. Select a table,
  4. Click on CREATE
--- a few seconds later a new GUI appears.

Walk Through. Here are those steps in a little more detail (including setting up your system with Java and the JGuiGen code)

Here are some screen shots that give you a quick walk through that shows just how easily you can create a GUI from an existing SQL table. The JGuiGen ScreenCast shows you how to create a new table if you aren't working with an existing table.

There are nine steps between you and a working GUI.

  1. You need a fairly recent copy (1.4.2_8 or newer) of Java. The ReadMe.html file shows how to get a new copy of java on a Windows PC or a Linux PC. The Sun site is You need to be sure to get the SDK or JDK versions (Developer Versions). The JRE (Runtime versions) don't have the compiler and other things you will need.

  2. You need a copy of svn (or on Windows you can use Tortisesvn). Most Linux distribution come with a working copy of svn. and

  3. You need a copy of the JGuiGen Software. You can download the last stable release ( or the most recent version using sebversion (we try very hard to make sure the current version is a working copy) using the command

    svn checkout jguigen

    Here is the subversion command in Windows

    and Linux

    Note: The two arrows point to the "checkout" command and the folder that will be created to contain the project. This folder will be one level deeper than the place where the "svn" command was given.

  4. You will need to cd into the new folder (where the checkout is) and unzip the file. This contains the database and properties files. We usually do NOT want these committed back to the SVN repository since they will become unique to your site.
    Here is the Windows version (the Linux version is identical except for th folder names.)

  5. You will need to make sure your JAVA_HOME environment variable is set.. You can type set {ENTER} and browse through the list of variables to see if it is already set.

    In Windows you run the command Start --> Settings --> Control Panel or Start --> Control Panel. Click on the System icon and choose the Advanced tab and click on "Environment Settings"

    On a Linux box, you need to export the JAVA_HOME path setting.

  6. Compile the code. The previous screen shows the Linux command (./ The windows command is simply build.

    This script/batch file does the following:

    • Reminds you if you didn't unzip the file (not shown here)
    • Tells you about setting the JAVA_HOME environment variable
    • Mentions you may get an error the first time run since the folder "work" does not exist
    • Compiles all of the java code you just downloaded
    • Tells you how to run JGuiGen (runJGuiGen.bat or ./
    • Tells you how to run classes that you generate (run src.{classname} or ./ src.{classname})
    • Tells you how to run classes with another language (run -Duser.language=es src.{classname} or ./ -Duser.language-es src.{classname})

  7. You need a table in a SQL database to work with. JGuiGen comes with several (userlogdata and tester3 are both there for your use) or you can see the ReadMe.html file for information about running JGuiGen against tables in your own SQL database.

  8. run JGuiGen (type runJGuiGen {ENTER} or ./ {ENTER})

    Once you type runJGuiGen (or ./, a list of users appears. This comes from an XML files that contains setup information. (There is a more secure version described in the manual.) Highlight a user and click on the SELECT button.

    There is a log file (called the History file) that is updated when new versions of JGuiGen are released. Each user is shown this file once (although it is available in the Help Menu at any time.) You will be asked if you want to view this file now. The first time you run you will be asked to identify a web browser and a word processor. (You can change these setting in JGuiGen or via the right Click pop-up menu later.)

    Here are the Linux versions of the prompts you will see. The Windows versions are the same except for the applications and paths.

    At this point the JGuiGen Screen comes up. You can either click on the Users-->JGuiGen Demo option to see an existing application OR click on Create --> Select a Table --> Create button and generate an application.

  9. Once you have generated the application you can use the Quick Create Options to make changes in the data_dict table (which drives the generation), close the new application and click on CREATE to generate it again.

    For example, the arrows point to the following:

    • You can edit things about the entire class (e.g. where the menu is and how it looks, how many rows appear in the scrolling table of data, what image should appear on the title bar, etc.)
    • You can change the order that the visual components appear on the screen.
    • You can edit things about a particular visual component (e.g. whether it appears in the GUI or the scrolling table of data, its tooltip, its mask, its visual component type -combobox, radio button, text field, etc.)
    • You can edit the wording of prompts that appear on the screen.
    • The two arrows at the bottom of the screen show that you can run the screen immediately (without regenerating it) or run a set of JUnit tests that fill the screen, save it, query the table for the data and check to see if the data matches what was originally filled into the different fields.)
    • Pressing the help button brings up a screen that describes the various options available from this screen.

The JGuiGen Project has seven major objectives

  1. GENERATE CRUD APPLICATIONS - JGuiGen creates a JPanel class for each table in your database with the standard edit/add/delete/search/view functions. These classes are designed to be merged into a larger project. JGuiGen is NOT a WYSIWYG GUI generator. The modern acronym is CRUD (Create, Read, Update, and Delete). JGuiGen adds FIND and REPORT to this list. Virtually every database project ends up needing to an edit screen for every table in the database. These might be standalone applications or they may be part of a larger application. JGuiGen can help automate the creation of these applications. The generated applications address many issues such as internationalization, accessibility, multi-user, saving user preferences, and on and on.

  2. ACCESS DATABASES - Real world applications almost always need to talk to SQL databases. A lot of the JGuiGen code addresses accurately reading and writing to SQL table, reporting, notifying users and logging error messages, handling multi-user conflicts and more. JGuiGen code has been written to accommodate different SQL back ends.. It can be modified easily. to handle new databases. As of February 2006, it is known to work with PostgreSQL, MySQL, Hypersonic SQL, SQL-Server, Oracle and MS Access. It comes with notes about how these back ends differ and how to manage data for each type of database. Any SQL database with a JDBC driver could be accessed by JGuiGen applications (with a little setup.)

  3. DATA DICTIONARY - Developers need to document tables in their SQL database. JGuiGen does this automatically by placing a record for each column in your tables into a special data_dict table and letting you annotate each field. A listing of fields, notes about the fields and when fields were added or changed can be generated at any time. Since JGuiGen queries the actual tables and updates the data-dictionary, the listing (except for the notes and usage comments) is guaranteed to be up-to-date. This code has many features. These features are described in detail in the Swing demo and are summarized below..

  4. USEFUL CLASSES - The third part of JGuiGen is a library of Java Classes to help in creating GUI front ends to your database tables. The project includes a number of classes gathered from various places that will help in creating GUIs. For example there is A) a simple row layout manager, B) a JTable where each column is sortable and resizable, C) a JTextField that will not allow more characters to be entered than exist in your table and D) JTextField classes for entering Integers or Floating Point numbers E) a JSearchableComboBox that shows you the first option that matches the letters you have typed so far. F) Special JTextFields for entering SSNs, IP numbers, telephone numbers and more.

  5. JAVA SWING EDUCATON - Another major objective of JGuiGen is to help educate developers on techniques need to write real-world rich client applications. Part of this is done by generating annotated Swing Code that can be viewed on a web Site. The Swing Demo discusses and shows this code.

  6. CODE GENERATOR - DEVELOP CODE THAT WRITES CODE - A major part of the JGuiGen project evolved out of necessity. JGuiGen is code that writes code. It became obvious that we needed to develop a code generator that did more than just write out lines of code using what were basically print statements. JGuiGen now reads working java class files that have been specially marked-up. Through a system of merges from information in the Data Dictionary JGuiGen writes out a modified version of the working code that works on a new SQL table. This part of JGuiGen is still under active development. It will make it much easier to modify the code that JGuiGen generates and add features.

  7. JGUIGEN REPLICATION SYSTEM - Many desktop applications need to run stand-alone and in a shared environment. The stand-alone versions often need to synchronize (replicate) their data with a home site. The developer of JGuiGen is migrating code from a system that successfully replicated dozens of sites to Java and the JGuiGen project. This replication system will also be used to migrate JGuiGen data from the HSQL database it ships with to other database such as mySQL, Oracle, and others.


The documentation for JGuiGen is divided into three parts. The part that describes the classes that make up JGuiGen and the menu options for the various screens is contained in the manual. This also includes the Swing Demo which is a set of notes on using Swing in a real-world application. The other part of the documentation is the description of how to setup JGuiGen on your system and use it with different SQL backend databases. This part is contained in the ReadMe.HTML file.

View Manual online (includes Swing Demo) Manual/help

View the extensive ReadMe.html file online for configuration and operation of JGuiGen ReadMe.html

View the 35 page (plus) specification for the JGuiGen Replication System JGReplication.html

You can view the Wiki where we are developing a demo and keeping active notes about bugs and insuring JGuiGen runs on Linux as well as Windoze. JGuiGen Demo on the wiki

JGuiGen is a set of Java Classes to help in creating GUI front ends to database tables. The project includes a number of classes gathered from various places that will help in creating GUIs. For example there is a simple row layout manager, a scrolling table of your data where each column is sortable, a JTextField that will not allow more characters to be entered than exist in your table. Right now the JGuiGen code works with PostgreSQL, MySQL, Hypersonic SQL, MS SQL-Server, Oracle and MS Access. It could be modified easily to handle other SQL database systems. In addition to these classes, the program will generate code that uses these classes and creates a CRUD (Create, Read, Update, Delete) application for one or more of the tables in your database.


Here are some screenshots that will give you an overview of what is contained in JGuiGen

Let's Start with a screen that shows you the finished product when you generate an application using JGuiGen. This screen is part of JGuiGen's Dictionary Edit and was generated by JGuiGen. These are the options available for describing a column in a table

JGuiGen Created GUI

Now let's look at the Quick Create Screen. At its simplest, you select a table and click on the Create button. JGuiGen writes a CRUD GUI for the table you selected, compiles it and runs it. Make some changes with the other buttons, click on Create again and see you modified GUI.

Quick Create

JGuiGen tries to make sure that you don't lose edits that you made. If you try to do something that would move to editing another record without pressing SAVE you might see something like this



In addition to the CRUD system (Create, Review, Update, and Delete), JGuiGen also generates a simple SQL Query Builder that is tailored to your data.

Another important feature of JGuiGen is access to a simple report writer.


As mentioned above, JGuiGen itself and the code it generates work with several different back end databases. By simply changing a few lines in the JGuiGenINI.xml file you can access a different database JDBC driver and your application will continue to run (assuming you have the same tables in each database.) Of course it also runs on differnt operating systems such as Linux or Windows. Other databases can be added very easily and JGuiGen should run on other operating system. I just haven't tried it yet. JGuiGen comes with the JDBC drives for all of the databases it can access except Oracle. I tell you where to obtain that driver but I can't ship it due to restrictions made by Oracle that I can't meet. JGuiGen current works with HSQL (Hypersonic - a small SQL engine that is downloaded with JGuiGen), MySQL, MS SQL Server, Oracle, PostgreSQL and MS Access.


JGuiGen works with a data_dictionary table that is built by querying the meta-data from a SQL database table and placing the results into an editable table (the data dictionary). This is called checking the data dictionary. When you Run the Data Dictionary CHECK you get a listing that shows all the columns in your table and describes changes, additions and deletions:


All application screen generated by JGuiGen have a right-click pop-up menu. All of the options on the main menu are available here. There are several menu options that are only available here.


There are a number of way that JGuiGen addresses accessibility for handicapped users. One example is the dashed red border around required fields. This helps the color blind see that a field is required.

Here are the special keys and features that are available in all applications generated with JGuiGen:


Here is a partial list of classes that are included and used by JGuiGen. These are described in more detail in the Manual.

VII Mini Swing Demo

Note: There is a much more extensive Swing Demo in the Manual

View Manual online Manual/help

Generating Swing applications in Java that meet modern standards involves addressing a lot of different concerns. As a result there is a lot going on in JGuiGen generated screens. The following images highlight some of the code that is generated and how it addresses things that every Java GUI application must address. Each of the highlighted sections is demonstrated in the code and is (or will be) addressed in the Manual.

Top Part of Screen

  1. General Background items
    • Pluggable Look and Feel
    • Ready to run on Windows or Linux client PCs.
    • Ready to run from class code, jars, or Java Web Start
    • Contains all the code needed to access a SQL back end. Database access is controlled from an XML file which contains the database URL, account and password.
    • I18N - generate screens that are internationalized (labels, and correctly formatted dates, numbers, phone numbers, etc.)
    • A11y - generate screens are accessible to assistive technology
    • JUnit- automatically generate a set of associated JUnit tests to the GUI screen.
    • Placement of windows on screen and size of windows is saved and restored for each user.
    • Modal versus non-modal windows
    • Generated classes can be run from a file system, from jars, or from Java Web Start
    • Each screen is "garbage collectible" when it closes
    • Common components are Inherited from your own subclasses of Java classes
    • Model - Delegate code is generated by using AbstractTableModel
    • The application has its own console for displaying SQL commands and errors
    • Interfacing JDBC and Swing Components - reliable updates and data integrity
    • Automatic fields such as date-row-last-changed or who-last-changed-row
    • JPanels can be placed inside other JPanels without losing screen space to margins.
    • Cursor shape during and progress bars long operations
    • Progress bar during long operations
    • Working with Scrollable JPanels
  2. Check that there are no unsaved changes before allowing window to close Borders
  3. Use a JTextField that does not allow too many characters to be entered
  4. Using a border to indicate required fields
  5. Making a field non-editable
  6. Placing tooltips and accessible name and descriptions on each component
  7. Forcing proper format of phone numbers - Cursor/Caret Placement in Component
  8. Hot Keys associated with JTextBoxes
  9. Loading data from SQL back end
  10. Replacing the Coffee Cup with your own image
  11. Changing the screen title
  12. Here is the same screen in Spanish (I18N).

    Spanish Screen


    Here is the middle portion of the screen and some important Java GUI issues that are addressed.

    Middle Portion of the Screen

    1. Check for valid email address format
    2. Force correct Social Security Number format
    3. Hot Keys on JCheckBoxes
    4. Hot Keys on JButtons
    5. Radio Buttons - hot keys, boarders, creating from an external file and more
    6. Validating the two letter code for State of residence - JSearchableComboBox
    7. JTextArea
      • Adding Scroll bars
      • Line wrap
      • Word wrap
      • Tabbing out of JTextArea Component
    8. Forcing only Integers to be entered
    9. Hot Key for JTextArea
    10. JComboBox - Filling from XML file or from a SQL table
    11. Hot Key for JComboBox
    12. Handling Dates - Pop-up calendar, Swing, SQL


    JTable Portion of the Screen

    JTable Part of Screen
    1. Column Headers
    2. Labeled border
    3. Sort on any Column - Click header again to sort descending - internationalized
    4. Special component to view all of the data in a text column
    5. Scroll Bars
    6. Click on a row
      • Check if there are unsaved changes to current data.
      • Stay on current row if true
      • Populate a row with changes after a save without ro-doing the whole table
      • Obtain new data from SQL database and populate row and components
    7. Special cell renderers for numbers, dates, and checkboxes
    8. Change column widths


    Menu Items can be displayed several ways. Here is one:

    Menu with Text and Icons


    Here is another format with some Java issues listed:

    Menu with Text

    1. Width between buttons
    2. Mouse-rollover and show Active button
    3. Multi-User code. Make sure the row has not been edited by someone else while your were editing
    4. Check that there are not unsaved changes - close screen - recover memory
    5. Print Screen code that resizes large screen to fit on one page
    6. Java Help Code - retrieves the proper internationalized version of the help code.
    7. Check that there are not unsaved changes - clear screen for ADD
    8. Delete a row or mark a row as "inactive"
    9. Not shown here is FIND button that pops up a simple SQL WHERE clause builder. A user can fill in information using drop down comboboxes and the system will select just the rows they indicate.

      Pringle Enterprises - JGuiGen is licensed under the GNU General Public License 1.0 Logo