|
SpeedJG - XML based Java Swing GUI BuilderJava Swing GUI Builder - IntroductionIn order that you become familiar with the handling of the SpeedJG GUI builder tool, this page is to introduce you to the basic essentials of the user interface, so that you are quickly in a position to develop your own Java GUI application. The following picture shows the main window of the SpeedJG GUI builder, consisting of different areas of operation that are explained below.
Tree Navigation Panel
Editors Panel
The Editors Panel consists of different tabs showing you the components you're currently working on. The properties of the components will be defined here and are presented in respect of the component currently being edited. For example, a JFrame editor only shows those properties that make sense for a JFrame and and not all the Component and Container properties a JFrame as inheritor hypothetically accepts. Thus the developer of a GUI is focused on the main properties when customizing a component, and he is not overstressed with all possible properties from the inheritance hierarchy in alphabetical order. Instead, only those properties which are relevant are presented and ordered by importance. The buttons shown on the bottom of these editor tabs refer only to the active Component being edited and have the following functions:
The properties on the Editors Panel normally are self-explanatory and correspond to the properties the correlating Java Component understands. To activate a property the corresponding check boxes have to be marked. There are, however, some virtual properties interpreted by the GUI builder to fulfill the requested feature:
Every Component has (and must have) a name that identifies it within the generated source code. This name becomes the variable name of the Component, and this is the name you use to fetch Components from a repository to get a reference to them. The Dynamic check box is used to tell the GUI builder not to add this Component to its parent container but to store it in the repository in any case. So, for example, if you have a group of Components alternatively to be laid out on a container, you can mark them as Dynamic, and later on use that Component you want to be shared in a given context.
The SizeRatio property allows you to define the size (width and/or height) of a Component dependent on the size of its container. X-MDR means x-axis multiply-divide ratio, and in the example above this component will become the width of one fifth of its parent container, and Y-MDR means y-axis multiply-divide ratio, in our example half the height of the parent container. If one of these width/height properties is not set, the corresponding Preferred Size property of the component is taken as the width or height. The PlusX and PlusY values define how many pixels additionally should be added to (or subtracted from if negative) this width or height.
The Title property intrinsically belongs to the JTabbedPane, but it is defined within those Components to be added to a JTabbedPane, and is used only in this context. This also is true for the Icon property in the above example. But I chose this example to demonstrate in general the usage of icons which are found on other property panels too. The button on the right allows you to open an embedded resource browser where you can search for icons in your file system and alternatively in your currently defined CLASSPATH. If the icon is selected from ClassPath or if you want the icon to be loaded from the ClassPath you have to mark the CP check box near the icon name. Thus you are able to deploy your icons within a .jar file and the GUI builder context and/or the generated code will load them from there.
While editing JList, JComboBox or JTree Components you may construct an underlying model based on a Text ItemSource or on a XMLFile ItemSource. The example above shows how to construct a text-based DefaultTreeModel with Colors as the root node and red, green, blue as the leaves. But like for icons you can also use the embedded resource browser to look for an XML file either in the file system or in your CLASSPATH. If you select this file the GUI builder constructs a tree model based on this XML file and visualizes all elements in it as nodes.
The Remarks property allows you to add comments to your component properties. This text is also visible as Java comment in the generated code. Output Panel
The Output Panel is implemented as JTabbedPane. If any output is generated by the GUI builder, the corresponding tab will be selected automatically. These tabs are headed as:
Tool BarsAs mentioned above all the toolbar buttons will be activated/deactivated in dependency on the Component selected in the tree. That is to say, if a toolbar button is active it refers to the Component currently selected. To give you a short overview of what these buttons mean and what functionality is associated with them, the events initiated by these buttons are explained below.
Presents a file dialog you can select a SpeedJG project file from and visualizes the structure of this file within the tree panel.
At this point there is something to say about the structure of the XML meta data.
As you can see on the first picture of this page, the root of this structure
begins with
Stores the contents of the project currently selected on the hard disk. This button is activated only if the underlying meta data have been changed.
Removes the selected project from the tree. If the meta data of the project have been changed, you will be asked to save the contents before closing.
When pressed instantiates a new project editor on the Editors Tab.
Opens a new editor for the Project currently selected on the Editors Tab.
Removes the Java Component currently selected from the tree structure and stores the contents of this Component (and all of its sub-components) into a separate copy buffer. In addition there is a cut history buffer where up to the last 50 cut components will be stored and from where they can be restored if required.
Stores the contents of this Component (and all of its sub-components) into a seperate copy buffer.
Fetches the component structure currently located in the copy buffer and adds this structure to the component structure currently selected in the tree.
Changes the order of Components at the same structure level by placing the Component currently selected before the preceding one.
Changes the order of Components at the same structure level by placing the Component currently selected after the following one.
Opens a dialog from where a previously cut component structure can be selected. This structure is than stored into the copy buffer from where it can be pasted to any place of the current tree structure.
Opens a new editor for the Component currently selected on the Editors Tab.
Following the model-view controller pattern the view and controller-code
generation is separated (the model code is up to you because it is not GUI
specific). When you create this code you see that the controller is given
a
When activating this button you will first be asked within a little dialog which Listeners to implement for which components. Here you can select any combination of:
Prints the readable and parseable structure of the Component currently selected on the XML Panel.
Instantiates a new Component from the selected XML meta-data structure on the fly. If this Component is a JFrame or JDialog it will be shown as a separate window. Otherwise it will be placed on the Check Panel.
The rest of the toolbar buttons are used to instanciate corresponding Component editors. These editors are customized with regard to the Component to be created. After editing this Component becomes part of the Component currently selected in the tree. So you are able to create the following GUI elements:
Copyright © 2003 Wöhrmann Softwareentwicklung
Java and all Java related trademarks and logos are trademarks of Sun Microsystems, Inc. |