JGuiGen - a Java GUI Generation System
Elegant CRUD
(Create/Read/Update/Delete)
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 ...
- JGuiGen Demo Screencast 13 minutes
- This Screencast shows some features your users will get when you generate a GUI using JGuiGen
- created on 20060510 using revision 235
- the JGuiGenDemo Script
- JGuiGen Screencast 14 minutes
- In this demo, we show how you can quickly generate a GUI.
- created on 20060512 using revision 235
- the JGuiGen Lead Script
- the JGuiGen Demo in Wiki
The most current version code is available for download using subversion.
The subversion URL is https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk/
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.
- Run JGuiGen,
- Click on CREATE,
- Select a table,
- 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.
- 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
http://javasoft.com. 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.
- You need a copy of svn (or on Windows you can use Tortisesvn). Most Linux distribution come with
a working copy of svn.
tortoisesvn.tigris.org/download.html and
http://subversion.tigris.org
- You need a copy of the JGuiGen Software. You can download the last stable release
(http://sf.net/projects/jguigen 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 https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk 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.
- You will need to cd into the new folder (where the checkout is) and unzip the
JGuiGenMisc.zip 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.)
- 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.
- Compile the code. The previous screen shows the Linux command (./build.sh).
The windows command is simply build.
This script/batch file does the following:
- Reminds you if you didn't unzip the JGuiGenMisc.zip 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 ./runJGuiGen.sh)
- Tells you how to run classes that you generate (run src.{classname} or ./run.sh src.{classname})
- Tells you how to run classes with another language (run -Duser.language=es src.{classname}
or ./run.sh -Duser.language-es src.{classname})
- 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.
- run JGuiGen (type runJGuiGen {ENTER} or ./runJGuiGen.sh {ENTER})
Once you type runJGuiGen (or ./runJGuiGen.sh), 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.
-
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
- 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.
- 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.)
- 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 -
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.
- 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.
DOCUMENTATION
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.
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 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.
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. JGuiGen
current works with HSQL (Hypersonic - a small SQL engine that is downloaded with JGuiGen),
MySQL, MS SQL Server, Oracle, PostgreSQL and MS Access.
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. POP-UP MENU OPTIONS
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.
- Duplicate - this option duplicates the current record. Only the ID number is changed.
- Replicate - activate the JGuiGen Replication System to synchronize local files
with the home office.
- Frequency Count - this option will generate a screen that frequency counts the last
column you sorted in the scrolling table. (Click on a column header to sort on a column and the
right-click and choose "Freq Count" to get a screen that looks this .
There are several things to note about this screen:
- The current SQL Where clause filter is used to generate this table.
- You get a value and the number of times this values appears.
- You get the percentage of the total that this value makes up.
- You can check mark selected values as "Missing" and Re-Calculate. Then you will also
get the percentage of the adjusted count that each values makes up.
- If the column is numeric, you will also be given the mean and the adjusted mean.
- The Frequency Count table "remembers" which items you marked ask missing and defaults
to marking those same values as missing when you run a frequency count on the same column again.
- You can export the table to a file that Excel can read and to the clipboard on your machine.
- Next and Previous row - this will move the "current row" in the scrolling table.
- Refresh Table - this option queries the SQL database and updates the scrolling table
at the bottom of the screen.
- A11y (Accessibility)- this opens a sub-menu with two options:
- A Magnifying glass - opens a small window that contains the contents under the cursor
in double size.
- An A11y Debug Screen - this opens a secondary screen that shows the component under
the mouse cursor and details what information will be available to devices that serve the h
handicapped (such as readers for the blind.)
- Switch Look and Feel - this option will give you a list of Look and Feel's available
on this PC. One is Native - the Look and Feel of the current Operating system and another
is Special - which is a look and feel you can modify to match corporate standards. When you
exit a JGuiGen screen it saves the current Look and Feel and will use that one in the future.
- Change Locales - JGuiGen is fully internationalized and since many items are shared
across differnt applications your application will be partially translated as soon as you
generate it. For example:
Spanish
French
German
Italian
- Change Font - Click on this option and you will see a list of Fonts available on the
current PC. Choose one and the screen will attempt to render itself in that font.
(Note that sometimes you will need to exit the screen and re-enter it for the font to
work properly.)
V. ACCESSIBILITY - A11y
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:
-
All Visual Components has accessible names and
accessible descriptions filled in. Some are modified especially for
software readers-for-the-blind. For example text boxes as "Enter last
name" instead of just "Last Name".
-
Hot keys are available for all menu options and labels.
These are set in the internationalization screen so that they can
change from one language to the next.
-
The Pop-up menu is accessible via the keyboard
(Shift-ESC)
-
Resizing columns in a JTable is possible via the
keyboard (CTRL-UP_ARROW and CTRL-DOWN_ARROW)
-
Rearranging columns in a JTable can be done with the
keyboard (SHIFT-LEFT_ARROW and SHIFT-RIGHT_ARROW)
-
Sorting on a column (click header) in a JTable can be
done via the keyboard (CTRL-ENTER)
-
Magnifying Glass is part of the pop-up menu
-
Supplemental A11y screen that shows accessibility of
component under mouse cursor.
-
There are special look and feels (such as the Low
Vision/High Contrast) look and feel) available for handicapped users.
-
One of the look-and-feels takes it colors and fonts
from the current system. If a user has set their PC to special colors
and fonts that make things more visible, these will be used by the
JGuiGen generated application.
-
The user can choose their own fonts and font sizes to
help make text more visible.
VI. 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.
- Frequency Count routine - Create a table that shows a count of the values in a column
in a result set.
- 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.
- Switch Look and Feel menu
- Change Locale menu
- Change Font menu
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
- 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 ro-doing 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.
Pringle Enterprises - JGuiGen is licensed under the GNU General Public License 1.0