Web server application - Chapter 13 Graphical User Interface Components: Part 2

Chapter 13 Graphical User Interface Components: Part 2 763 // Fig. 13.13: DesktopTest.java // Demonstrating JDesktopPane. // Java core packages import java.awt.*; import java.awt.event.*; // Java extension packages import javax.swing.*; public class DesktopTest extends JFrame { private JDesktopPane theDesktop; // set up GUI public DesktopTest() { super( “Using a JDesktopPane” ); // create menu bar, menu and menu item JMenuBar bar = new JMenuBar(); JMenu addMenu = new JMenu( “Add” ); JMenuItem newFrame = new JMenuItem( “Internal Frame” ); addMenu.add( newFrame ); bar.add( addMenu ); setJMenuBar( bar ); // set up desktop theDesktop = new JDesktopPane(); getContentPane().add( theDesktop ); // set up listener for newFrame menu item newFrame.addActionListener( // anonymous inner class to handle menu item event new ActionListener() { // display new internal window public void actionPerformed( ActionEvent event ) { // create internal frame JInternalFrame frame = new JInternalFrame( “Internal Frame”, true, true, true, true ); // attach panel to internal frame content pane Container container = frame.getContentPane(); MyJPanel panel = new MyJPanel(); container.add( panel, BorderLayout.CENTER ); // set size internal frame to size of its contents frame.pack(); Fig. 13.13 Fig. 13.13 Creating a multiple document interface (part 1 of 3).
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision personal web hosting services

Leave a Reply