Java Reference
In-Depth Information
You have done well, Grasshopper. For all your hard work, we will now use something fun, the Visual Editor (VE).
In addition to being fun, VE will save you from a lot of coding and let you create GUIs faster and with fewer errors.
Visual Editor
The Visual Editor (VE) is a GUI tool that makes it much easier to define visual classes. VE will automatically be invoked
when creating a visual class. You can also use VE to edit any class by right-clicking on the class in the navigation tree
and selecting Open With , then Visual Editor . However, source code that does not follow VE coding standards is
not easy to change with VE. So, the bottom line is that when using VE, it is best to start with a new class. In addition,
VE's source code may seem very confusing at first. As with any “source code generator,” the source code is more
complex than is usually necessary. (For instance, if you generate a Web page using page generator, the HTML source is
unbelievably complex and bewildering.) Generators do this so that the most complex enhancements can be added to
the source code. So be aware that there is a downside when dealing with VE or any tool that generates source code.
Tutorial: Creating a Visual Class with VE
Let's use VE to create a new frame with some added bells and whistles.
1.
Select c4 in the navigation tree, and then click File , New , and Visual Class .
The “New Java Visual Class” window will be displayed. It has all the options as the “New Java Class” window (that
we have used previously) plus a Style pane in the lower left. The Style pane allows you to choose the superclass from a
navigation tree. The navigation tree contains all the visual components in the three GUI sets. In this case, however, we
want our new frame to be a subclass of UsefulFrame.
2.
First, specify EmployeeFrame as the class name.
3.
In the Style navigation tree, click Other and then click the Browse button.
4.
In the Choose a type field type c4. over the default value of java.lang.Object and when the
UsefulFrame item is displayed, double click UsefulFrame.
5.
Click the Finish button.
VE crams a lot into the content pane. (You may have to resize the content pane to get it to look like Figure 4-5 .)
Essentially, VE divides the content pane into three areas: a palette of components (on the right), the Design area
(at the top), and the source code (on the bottom). These areas can be resized by clicking and dragging the dividing
borders or minimized and maximized by clicking the small arrowheads (indicated by the big arrows in Figure 4-5 ).
 
Search WWH ::




Custom Search