The First AbaGUIBuilder Demo: The Person Application
The AbaGUIBuilder can also provide you with instant feedback about your GUI application's look and feel as you build it. Its IDE Rendering mode helps you put an application together in just a few minutes (see Figure 2 for a sample application called Person) and render it within the GUI to see exactly how the application will look like once you run the jar (see Figure 3 for a rendering of Person).
As you can see, the Person application has two panels with multiple JTextFields and JLabels, and a pair of buttons. You can build this application in a few minutes using AbaGUIBuilder.
After you "Save and Compile" a form, the builder stores the project definition in a .proj file. It then creates an application jar and a project declaration file (proj.decl). The declaration file has Java code fragments with object declarations and an access method with all the visual objects on the form, which you can use for development later.
Running the Person Application
To run an application jar, you need to write a small Java program that instantiates an AbaRenderer object. The object loads and renders the application jar. Abacus recommends initially using the runproz script and the wrapper program in the AbaGUIBuilder's samples directory until you get familiar with the rendering process (see Figure 4
The runproz script adds all the required jars to the classpath and executes the sample wrapper exec.java. To test your application jar, copy it into the samples directory and run it with the following runproz script:
|Figure 5. Adding Option Dialog to an Event Handler|
The execute.java wrapper in turn instantiates an AbaRenderer object, loads the application jar, and runs the application (see Listing 1).
Adding Object Event Handlers
Adding code to events is a critical phase to any GUI application project, and the AbaGUIBuilder makes adding event handlers a snap. Just select the object from the canvas, choose the event from the event dropdown, and write the Java code in the Event Source and Object panel. The builder hides the listener code and presents event handling in a paradigm similar to Visual Basic or Delphi. Internally, the IDE manufactures a listener class that's added to the visual object at rendering time.
If you want to add a confirmation dialog to exit the application, simply add an instance of the JOptionPane dialog to the actionPerformed event on JButton1. The event code in Figure 5 activates the JOptionPane dialog when the user clicks on the "Cancel" button.
Now, when the user clicks on the Cancel button, the JOption dialog pops up and queries the user for confirmation (see Figure 6).