Java Reference
In-Depth Information
Group components as necessary. Grouping components allows them to be
aligned and proportioned properly. It marks the transition from XY Lay-
out mode into grid layout mode , where their size and position are con-
trolled by the bounding grid.
3
Preview your form, if desired. Use the preview tool to test your user inter-
face to see that it looks as intended.
4
Bind your form and components to an application class. Using the GUI D esigner,
bind your form to one of your application classes. Also bind each impor-
tant component of your form to the instance variables within that class to
give you a handle to them. You can bind to existing classes or let IDEA cre-
ate them for you on the fly. Implement methods in that class that make the
form functional.
5
Compile and run your application. During the compilation phase, IDEA uses
the form object you've designed, as well as its bindings to your applica-
tion classes, to generate the code required to build and lay out your
interface. Forms don't become their own classes; they're more like tem-
plates used to generate the layout code within your application classes at
compile time. You never have to see the generated code if you so choose.
6
These steps describe the ideal situation when you have a simple form and
know exactly what it will contain. But in most real-world cases, you need
to maintain your existing form, adding, modifying or moving its compo-
nents. IDEA 's GUI Designer lets you work on existing forms without
breaking their layout so that you can easily introduce changes at any time.
TIP
10.1.2
Working with the user interface
Creating a new form or editing an existing one brings up the GUI Designer (see
figure 10.1). It's divided into four main areas: the Components Tree view, the
Properties Inspector, the GUI Designer toolbar, and the Form Workspace. You can
resize the areas as desired, but you can't rearrange them or split them off into
their own windows.
The Components Tree view is a hierarchical view of the current form. Each
component in your form appears in the tree under its parent container. For a sim-
ple form, there may be only a single level of hierarchy. It isn't uncommon for
complex interfaces to use many layers of nested containers of components to sim-
plify layout. Clicking a component selects it in the design window.
 
 
 
 
 
Search WWH ::




Custom Search