Java Reference
In-Depth Information
Note If you use the static creation methods of JOptionPane , the JDialog windows it creates automat-
ically have the Escape key registered to close the dialog.
Extending JDialog
If you need to extend JDialog , the class has two protected methods of importance:
protected void dialogInit()
protected JRootPane createRootPane()
The latter method is demonstrated in the previous example in Listing 8-4.
JApplet Class
The JApplet class is an extension to the AWT Applet class. For event handling to work properly
within applets that use Swing components, your applets must subclass JApplet instead of
Applet .
The JApplet works the same as the other high-level containers by implementing the
RootPaneContainer interface. One important difference between JApplet and Applet is the default
layout manager. Because you add components to the content pane of a JApplet , its default
layout manager is BorderLayout . This is unlike the default layout manager of Applet , which is
FlowLayout . In addition, Swing applets can also have a menu bar, or more specifically a JMenuBar ,
which is just another attribute of the JRootPane of the applet.
If you plan to deploy an applet that uses the Swing components, it is best to use the Java
Plug-in from Sun Microsystems, because that will install the Swing libraries with the runtime.
Tip To make sure you are running the Java Plug-in under Internet Explorer, select Internet Options from
the Tools menu, and then choose the Advanced tab. Scroll down to the Java section immediately above
Microsoft VM and make sure Use JRE [VERSION] for <applet> (requires restart) is selected. If [VERSION] isn't
recent enough, you'll need to get a newer version from Sun at http://www.java.com .
If you need to extend the JApplet class, it has only one protected method of importance:
protected JRootPane createRootPane()
Working with a Desktop
Swing provides for the management of a set of frames within a common window or desktop. As
discussed in Chapter 1, this management is commonly called MDI. The frames can be layered
on top of one another or dragged around, and their appearance is specific to the current
look and feel. The frames are instances of the JInternalFrame class, whereas the desktop is a
specialized JLayeredPane called JDesktopPane . The management of the frames within a desktop
is the responsibility of a DesktopManager , in which the default implementation that's provided
is DefaultDesktopManager . The iconified form of a JInternalFrame on the desktop is represented
 
Search WWH ::




Custom Search