Java Reference
In-Depth Information
Creating graphical user interfaces ( GUI s) for your applications in Java using Swing
components is a necessary yet tedious task. The Swing component architecture may
be very flexible and allow for very complex and powerful GUI s to be modeled, but
implementing even a simple dialog can be a time-consuming process.
IDEA includes a GUI Designer that automates many of the monotonous
aspects of GUI design in Java. By implementing an additional abstraction layer,
IDEA lets you build dialogs or panels of GUI components more efficiently than
writing pure Java Swing code. The abstraction layer lets you design your interface
visually, use tools to simplify some of the more complex aspects of GUI design in
Swing (such as layout managers), and bind underlying functionality in an on-the-
fly and modular fashion.
To illustrate some of the points in this chapter, we'll use IDEA 's GUI Designer
to implement a snazzy GUI atop the ACME Currency Converter.
10.1 Understanding the GUI Designer
Central to IDEA 's GUI Designer is the concept of a form, which is IDEA 's abstrac-
tion of a Java Swing GUI . Because implementing GUI s by hand in Java is time-
consuming and tedious, IDEA uses the concept of a form to improve efficiency. In
the editor, a form is shown in WYSIWYG format, allowing direct manipulation
through a point-and-click interface; on the disk, a form is stored as an XML file,
containing metadata about the GUI and all its constituent components. You can
easily implement all the GUI s in an application—a main screen interface, a sim-
ple About box, a Confirm Delete dialog, and so on—as forms.
10.1.1
The GUI-building process
Let's run through a quick overview of the typical process used to create GUI appli-
cations in IDEA . This chapter will cover each of the following steps in more detail,
but it will be helpful for you to have a notion of the process in general. Regardless
of the type and complexity of your specific interface, the steps required to build a
GUI using IDEA 's GUI Designer are the same:
Create a form by populating it with GUI components. Using the GUI Designer,
visually lay out all the components for your interface. Place the compo-
nents where they should generally appear, setting their approximate
sizes and positions. This flexible design mode is called XY Layout mode.
1
Customize the properties of your form. You can edit labels and most visual text
(such as the text shown on a button) directly in the design area. You can
edit other properties using the Properties Inspector.
2
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search