Java Reference
In-Depth Information
Dialog Windows (continued)
Figure 12.11
Output of the ModalDemo program.
Using No Layout Manager
You can create a GUI with components in the exact location and size that you
want. To do this, you set the layout manager of the container to null and then
set the bounds for each component within the container.
The following JDialogDemo program creates a JDialog and sets its layout
manager to null. Three components are added: a JLabel and two JButtons. The
bounds of each component are set using the setBounds() method. Because
there is no layout manager, the bounds of the component are not overridden
(as they often are when you are using a layout manager), causing the compo-
nents to appear exactly where you specify with setBounds(). Study the JDia-
logDemo program and try to determine what the GUI will look like. The
output is shown in Figure 12.12.
Figure 12.12
Output of the JDialogDemo program.
Search WWH ::




Custom Search