Brought to you by EarthWeb
ITKnowledge Logo Login Graphic Click Here!
Click Here!
ITKnowledge
Search this book:
 
Search the site:
 
EXPERT SEARCH ----- nav

EarthWeb Direct

EarthWeb Direct

EarthWeb sites: other sites

Previous Table of Contents Next


Chapter 17
Internal Frames

In This Chapter
•  The JInternalFrame Class
•  The JDesktopPane Class
•  Integrating JInternalFrame and JDesktopPane Usage

The success of programs like MS Word and Excel popularized the multiple document interface (MDI). This type of interface contains many frame windows contained in a single top-level frame. The internal frames can be sized, dragged, and iconified independently of the other frames. The single top-level frame groups the internal frames. If the top-level frame is iconified, the internal frames are iconified with it. The MDI allows all the views in an application to be contained in a single frame. This interface model is showing its age at this time and is being replaced by variants of the MDI.

The JFC contains the JInternalFrame and JDesktopPane classes that provide a frame and a frame management pane that can be added to other frames. The internal frames are added to the desktop pane that interfaces with the desktop manager. The DesktopManager instance is responsible for managing look-and-feel–specific issues regarding frame decorations, closing, moving, and so on. These classes allow the application developer to create whatever interface he or she requires. A complete MDI interface is not provided in the JFC. Instead, the tools required to build any type of interface are provided.

In this chapter, you will learn

  How to use the JInternalFrame class
  How the JDesktopPane is used
  How to use the JInternalFrame and JDesktopPane classes together

The JInternalFrame Class

The JInternalFrame class provides a lightweight container sharing most of the features of the JFrame class. The fundamental difference between the two classes is that you can add a JInternalFrame instance to other frames, and a JFrame instance is a top-level window. The JInternalFrame class extends the JComponent class, while the JFrame class extends the AWT Frame class.

The discussion of the JRootPane class (and the panes it creates) being the single child of a JFrame instance presented in Chapter 8, “Frame Windows,” is valid for the JInternalFrame class and will not be repeated here. However, it is worth repeating that adding components and setting layout managers are performed on the content pane, not the internal frame itself. This technique will be demonstrated throughout this chapter.

A JInternalFrame instance appears similar to a top-level frame. It contains a titlebar and a border. The titlebar may contain a title, an icon, minimize and maximize buttons, and a close button. The window decoration is only shown if the internal frame supports the operation. A JInternalFrame created with the default constructor will not contain any of these decorations as the default state of an internal frame is not iconifiable, not maximizable, not closable, not resizable, and the title is empty. If the internal frame is resizable, the user can drag on the border to resize the frame. Each of these properties can be set individually with the setResizable, setClosable, setIconifiable, and setMaximizable methods. The current value of each of these properties can be queried with the is version of each method. For example, the isMaximizable method may be used to query the state of the maximizable property. These are not bound properties of the internal frame.

You can specify the title with the setTitle method and query it with the getTitle method. The title is a bound property of the JInternalFrame class. The icon for the internal frame can be set with the setFrameIcon method. The getFrameIcon method can be used to query the current icon associated with the internal frame. The frame icon is also a bound property of the class. The complete list of bound properties introduced in the JInternalFrame class is shown in Table 17.1. The property names are constants defined in the JInternalFrame class.

Table 17.1 Bound Properties Introduced in the JInternalFrame Class

Property Name Setter Method Getter Method

MENU_BAR_PROPERTY setMenuBar getMenuBar
MENU_BAR_PROPERTY setJMenuBar getJMenuBar
CONTENT_PANE_PROPERTY setContentPane getContentPane
LAYERED_PANE_PROPERTY setLayeredPane getLayeredPane
GLASS_PANE_PROPERTY setGlassPane getGlassPane
ROOT_PANE_PROPERTY setRootPane getRootPane
IS_CLOSED_PROPERTY setClosed isClosed
IS_ICON_PROPERTY setIcon isIcon
TITLE_PROPERTY setTitle getTitle
IS_SELECTED_PROPERTY setSelected isSelected
FRAME_ICON_PROPERTY setFrameIcon getFrameIcon


Note:  
It seems odd that pane properties are fired from the JInternalFrame class. The setter and getter methods are convenience methods that call the appropriate method of the JRootPane class. If the PropertyChangeEvent were fired from the JRootPane class, it would also be available from the JWindow, JFrame, and JDialog classes that also use the JRootPane class but do not fire a PropertyChangeEvent when one of the panes is changed.


Previous Table of Contents Next
HomeAbout UsSearchSubscribeAdvertising InfoContact UsFAQs
Use of this site is subject to certain Terms & Conditions.
Copyright (c) 1996-1999 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.