Java GUI Generation - JGuiGen

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.

SourceForge.net Logo

The JGuiGen Project has six 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, 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.

  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.

  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 - 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.

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

  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 redoing 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.

      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.

      1. Download the zip files at the halepringle.com website.
      2. Download the zip files from Sourceforge
      3. Download the most current source from Sourceforge using Subversion.

      The system involves several steps.

      1. You will need to have Java downloaded and installed as described above.
      2. 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.

      3. 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.

      4. 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

      5. 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.
        1. Hale's website - JGuiGen Code dated 4/10/2006,
        2. Hale's website - Jars Used by JGuiGen dated 4/10/2006
        3. Hale's website - Miscellaneous Files (download only once) by JGuiGen dated 4/10/2006

          Newer Version -

        4. Hale's website - JGuiGen Code dated 4/23/2006,
        5. Hale's website - Jars Used by JGuiGen dated 4/23/2006
        6. 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.

      6. 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.
      7. Also see the ReadMe.HTML file for instructions about setting your CLASSPATH so that the JGuiGen application will run properly.
      8. 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.
      9. 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.
      10. 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.
      11. 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.

      http://vernon.is-a-geek.org/mediawiki/index.php/Main_Page