Java Reference
In-Depth Information
Lines 27-33 create a JMenuBar , a JMenu and a JMenuItem , add the JMenuItem to the
JMenu , add the JMenu to the JMenuBar and set the JMenuBar for the application window.
When the user selects the JMenuItem newFrame , the application creates and displays a new
JInternalFrame object containing an image.
Line 35 assigns JDesktopPane (package javax.swing ) variable theDesktop a new
JDesktopPane object that will be used to manage the JInternalFrame child windows.
Line 36 adds the JDesktopPane to the JFrame . By default, the JDesktopPane is added to
the center of the content pane's BorderLayout , so the JDesktopPane expands to fill the
entire application window.
1
// Fig. 22.12: DesktopTest.java
2
// Demonstrating JDesktopPane.
3
import javax.swing.JFrame;
4
5
public class DesktopTest
6
{
7
public static void main(String[] args)
8
{
9
DesktopFrame desktopFrame = new DesktopFrame();
10
desktopFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
11
desktopFrame.setSize( 600 , 480 );
12
desktopFrame.setVisible( true );
13
}
14
} // end class DesktopTest
Internal frames
Minimize
Maximize
Close
Minimized internal frames
Position the mouse over any corner of a child window to resize
the window (if resizing is allowed)
Fig. 22.12 | Test class for DeskTopFrame . (Part 1 of 2.)
 
Search WWH ::




Custom Search