JGuiGen - a Java GUI Generation System
Elegant CRUD
(Create/Review/Update/Delete)
Pringle Enterprises - Licensed under
GNU License 1.0
JGuiGen is a java application designed to help developers who work with rich clients
and SQL back end databases. Links to the source code are at bottom of this screen -
either through Java Web Start or downloading the full source code.
Note; The JGuiGen project is now hosted on www.sourceforge.net. The most current version
code is available there for download using subversion. The subversion URL is
https:\\www.sourceforge.net\svnroot\jguigen\JGuiGen\trunk. You will need to
download a subversion client in order to obtain the source code this way. At this point
you will need to send patches/fixes to me. We will be adding other developers based on
their interest and expertise. I am working on getting this home page moved to
the sourceforge site as well.
The JGuiGen Project has six major objectives
- 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, Review, 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 inter nationalization, accessibility, multi-user,
saving user preferences, and on and on.
- 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.
- 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..
- 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.
- 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.
- CODE GENERATOR - DEVELOP CODE THAT WRITES CODE -
The last major objective 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.
DOCUMENTATION
The documentation for JGuiGen is divided into two 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 documentaion 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
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.
http://vernon.is-a-geek.org/mediawiki/index.php/JGuiGen_Demo
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.
I. GENERATE CRUD APPLICATIONS
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 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.
II. ACCESSING MULTIPLE DATABASES
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.
III. DATA DICTIONARY
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:
IV. USEFUL CLASSES FOR YOUR APPLICATIONS
Here is a partial list of classes that are included and used by JGuiGen. These
are described in more detail in the Manual.
- BoundedTextField.java - Creates a JTextField that will not accept more than x characters where you define the x value.
BoundedPlainDocument.java - part of BoundedTextField
- CustomViewer.java - This is a pop-up viewer for JTables. It allows you to view the contents of long strings or text fields.
- DateDialog.java - pop-up calendar for choosing a date.
- DoublyLinkedList.java - create two lists, side by side. Move items from side to the other in order
to select a group of options, features, tasks, people etc.
- GeneralDialog.java - a generic three button, give text and ask a question screen.
- GeneralDialog4Btn.java - a generic four button, give text and ask a question screen.
- GetBrowserAndWP.java - code to ask a user for the path to their word processor and Browser. These values are stored in a table and used to call up these applications as needed.
- History.java - code to view an HTML file. The date and time a user views the file is stored and they are only offered the option to view the file when it is newer than the one they last viewed. Used by a developer to notify users of changes in the application they are using.
- JFreeReports example - generate a report using an existing JTable of data.
- JSearchableComboBox.java - A JComboBox with "Look-ahead". It fills in the most probable
answer based upon what the user has entered so far. (This fills a much needed void in Java.
By default in a pup-up list if your user types FL for Florida they will get Louisiana. It goes
to Florida with the F and then Louisiana with the L. The look-ahead system will leave
them on Florida.
- JxFrame.java - a class to inherit instead of JFrame. This gives a single point to make modifications that will affect each frame in an entire application. This one adds the automatic determination of Look and Feel code. It also informs the system to make button more active.
- JxButton.java -a class to inherit instead of JButton. This gives a single point to make modifications that will affect each frame in an entire application.
- JxLabel.java - a class to inherit instead of JLabel. This gives a single point to make modifications that will affect each frame in an entire application.
- JxTextArea.java - a class to inherit instead of JTextArea. This gives a single point to make modifications that will affect each frame in an entire application. This one makes the tab key exit a JTextArea that is being edited. The default requires a user to press CTRL-Tab.
ListDialog.java - a generic screen to show a list that the user chooses an option from. It has an optional "Add a new value" feature.
- LowVisionMetalLookAndFeel.java - code to change the look and feel to very large text and very high contrast.
- MutableInteger.java - code to pass an integer value into a class and allow changes made in the class to be known by the calling class.
- NumericPlainDocument.java - Part of the Numeric TextField class.
- NumericTextField.java - creates a JTextField that accepts a number with a specified number of decimal places.
- ProgressMonitorDemo.java - and ProgressMonitorInc.java and ProgressMonitorWork.java. I found it very difficult to get the ProgressMonitor (a small pop-up that fills as your long running task runs) to work. I finally figured out something that works reliably and these three classes show how to do it.
- PrintScreen code - this code is included inside the various classes that JGuiGen generates.
- RegexFormatter.java - code to help apply a Regex value to a JFormattedText field
- RowLayout1.java - a layout manager that includes one column of labels and then a variable number of columns. This can be used for most business applications.
- RowLayoutConstraint.java - part of the rowlayout manager.
- SetIcon.java - code to replace the coffee cup icon on each frame.
- SQLWhereClause.java - a class to pop-up a simple SQL Where clause generator. It includes the
ability to name, save and rerun queries. It also saves and runs reports using JFreeReports.
- StreamEditorPane.java - Part of the TextEditor class.
- SwitchLF.java - code to switch look and feels in a running application.
- TableMap.java - part of the TableSorter class.
- TableSorter.java - code to make a JTable that sorts on each column when the column header is clicked.
- TernarySearchTree.java - part of the JSearchableComboBox class.
- TextViewer.java - Code to view a Text field.
- TextEditor.java - Code to edit a text field. This includes a way to make Tab exit a JTextArea (which
is not the default for Java.)
- TableHeaderJLabel.java - Code to display special headers over a column in a JTable.
- WholeNumberField.java - code to create a JTextField that will only accept integer values.
V 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
- 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
- Check that there are no unsaved changes before allowing window to close
Borders
- Use a JTextField that does not allow too many characters to be entered
- Using a border to indicate required fields
- Making a field non-editable
- Placing tooltips and accessible name and descriptions on each component
- Forcing proper format of phone numbers - Cursor/Caret Placement in Component
- Hot Keys associated with JTextBoxes
- Loading data from SQL back end
- Replacing the Coffee Cup with your own image
- Changing the screen title
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
- Check for valid email address format
- Force correct Social Security Number format
- Hot Keys on JCheckBoxes
- Hot Keys on JButtons
- Radio Buttons - hot keys, boarders, creating from an external file and more
- Validating the two letter code for State of residence - JSearchableComboBox
- JTextArea
- Adding Scroll bars
- Line wrap
- Word wrap
- Tabbing out of JTextArea Component
- Forcing only Integers to be entered
- Hot Key for JTextArea
- JComboBox - Filling from XML file or from a SQL table
- Hot Key for JComboBox
- Handling Dates - Pop-up calendar, Swing, SQL
JTable Portion of the Screen
JTable Part of Screen
- Column Headers
- Labeled border
- Sort on any Column - Click header again to sort descending - internationalized
- Special component to view all of the data in a text column
- Scroll Bars
- 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 redoing the whole table
- Obtain new data from SQL database and populate row and components
- Special cell renderers for numbers, dates, and checkboxes
- 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
- Width between buttons
- Mouse-rollover and show Active button
- Multi-User code. Make sure the row has not been edited by someone else while your were editing
- Check that there are not unsaved changes - close screen - recover memory
- Print Screen code that resizes large screen to fit on one page
- Java Help Code - retrieves the proper internationalized version of the help code.
- Check that there are not unsaved changes - clear screen for ADD
- Delete a row or mark a row as "inactive"
- 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.
Running the JGuiGen Code
There are two basic ways to try JGuiGen out.
1. JAVA WEB START
First you can see a sample that is already configured and running using Java Web
Start. In order to do this you will need to do the following steps
A. Load the Java 1.4.0+ JDK Standard Edition Environment from Sun MicroSystems
(tm). (It will be in the upper right hand corner of the page. Do NOT load the
BETA version.
Install Java
B.For experimentation purposes, you will be linking to a Hypersonic SQL table
that is downloaded as part of the application. This is a full featured SQL database
that can be installed by simply copying a few text files and a Java jar file..
C. Launch the JGuiGen System using Java Web Start (JAWS). NOTE: This is not
currently functional - you need to download the code below.
DO NOT USE - Launch JAWS JGuiGen Application
The program can be run from the WEB START Icon or you can copy a batch
file down that will launch the program directly. The batch file WILL NOT check
for updates. In the WEB START Program manager, you should go to the PREFERENCES
Screen and turn on JAVA CONSOLE and LOGGING in order to see what is happening
when errors occur.
You can create an icon on your desktop that points to this file by right
clicking on the start button, choosing explore and navigating to the c:\deliver
folder. Right click on the batch file (Deliver.bat) and choose Create a
Shortcut.
2. DOWNLOAD JGUIGEN SOURCE CODE
You can download the code in three ways.
- Download the zip files at the halepringle.com website.
- Download the zip files from Sourceforge
- Download the most current source from Sourceforge using Subversion.
The system involves several steps.
- You will need to have Java downloaded and installed as described above.
- I like to use the Eclipse IDE to run the application and work on it. You
can download the current version as Eclipse.org Notes on
using this IDE to run JGuiGen are contained in the ReadMe.html file. See the ReadMe.html
file for a Step by Step set of instructions on downloading Java, Eclipse and setting up your
project to run. There is one version in the Linux Considerations section and one coving
Windows.. I have tested this version on Linux and it appears to be working.
- Without using Eclipse you can
TYPE build.bat or ./build.sh to compile the code and then
TYPE run JGuiGen or ./run.sh JGuiGen to run JGuiGen or
TYPE run com\halepringle\src\JGuiGemo or ./run.sh
com/halepringle/src/JGuiGenDemo will run the demo that was generated with JGuiGen.
- We are very clore to finishing the video that walks through these steps. You can
see the current draft at
http://vernon.is-a-geek.org/mediawiki/index.php/Main_Page
- Copy down the code and
unsip it in a folder. This will be your project folder. I use
MYJPROJECTS/JGuiGen. You can put it anywhere that makes sense
to you.There are three files to download and unzip.
-
Hale's website - JGuiGen Code dated 4/10/2006,
-
Hale's website - Jars Used by JGuiGen dated 4/10/2006
-
Hale's website - Miscellaneous Files (download only once) by JGuiGen dated 4/10/2006
Newer Version -
-
Hale's website - JGuiGen Code dated 4/23/2006,
-
Hale's website - Jars Used by JGuiGen dated 4/23/2006
-
Miscellaneous Files (download only once) by JGuiGen dated 4/23/2006
More current copies can be obtained by installing the subversion version control client
and accessing the code from
svn checkout https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk jguigne
The last parameter placed the downloaded code into a folder called "jguigen"
The Miscellaneous files contains the .classpath files for Eclipse and the data files for the
Hypersonic SQL database used to demonstration and testing. By only downloading this file once
you will not lose the additions you have made. It also contains the Tester.java file which
is needed to make JGuiGen.java compile cleanly, but you may have overwritten with your own test
class.
NOTE: When you copy the code a second time OR when you generate code, you will
need to 1) Right Click on the JGuiGen Project (Upper left in the Java Perspective) and choose
REFRESH and 2) Projects --> Clean (Linux) or 2) Projects --> Build Project (Windows). The
objective here is to make sure the Eclipse recognizes that new java files have been added
to the project.
NOTE 2: The ReadMe.html and the manual (/htmlhelp.index.html) are downloaded
with the project. You can either browse them directly or when you get the main JGuiGen
screen to compile and execute you click view them through the Help Menu.
- See the ReadMe.HTML file for
instructions about the modification in the JGuiGenINI.xml and file and three
tables that need to be added to your database before JGuiGen has create
applications that will access your data.
- Also see the ReadMe.HTML file for
instructions about setting your CLASSPATH so that the JGuiGen application will run
properly.
- You will need to set the Java CLASSPATH as described in the ReadMe.HTML file. If you use
build.bat/build.sh and run.bat/run.sh scripts the classpath will be set for you.
- You can run the JGuiGen.java file as soon as you download the system. It comes
configured to work with the Hypersonic SQL database that is included.
- In order to work with tables from
your own database you will need to create three tables in your database. The ReadMe.html
file contains instructions for creating these files and prefilling the tables with
small java applications.
- Run the JGuiGen and click on Users-->
JGuiGenDom to view a file generateed by JGuiGen and then use the
Data Dictionary menu options as described the Manual to generate a new class.