Java Reference
In-Depth Information
Display 17.9
The GridLayout Manager (part 2 of 2)
R ESULTING GUI
First label Second label Third label
Fourth label Fifth label
Note that we have placed a demonstration main method in the class definition in
Display 17.9. This is handy, but is not typical. Normally, a Swing GUI is created and
displayed in a main method (or other method) in some class other than the class that
defines the GUI. However, it is perfectly legal and sometimes convenient to place a
main method in the GUI class definition so that it is easy to display a sample of the
GUI. Note that the main method that is given in the class itself is written in the same
way as a main method that is in some other class. In particular, you need to construct
an object of the class, as in the following line from the main method in Display 17.9:
GridLayoutJFrame gui = new GridLayoutJFrame(2, 3);
The three layout managers we have discussed are summarized in Display 17.10.
Next we will discuss panels, which will let you realize the full potential of layout
managers.
 
Search WWH ::




Custom Search