home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 6.1 KB | 196 lines |
- /*
- * @(#)JDesktopPane.java 1.14 98/02/06
- *
- * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
- *
- * This software is the confidential and proprietary information of Sun
- * Microsystems, Inc. ("Confidential Information"). You shall not
- * disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Sun.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
- * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
- * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
- * THIS SOFTWARE OR ITS DERIVATIVES.
- *
- */
-
- package java.awt.swing;
-
- import java.util.Vector;
- import java.awt.swing.plaf.*;
- import java.awt.accessibility.*;
-
- /**
- * This JLayeredPane subclass keeps a reference to a DesktopManager object.
- * This class in normally used as the parent of JInternalFrames to provide a
- * pluggable DesktopManager object to the JInternalFrames.
- * <p>
- * The installUI of the L&F specific implementation is responsible for setting
- * the desktopManager variable appropriately.
- * <p>
- * When the parent of a JInternalFrame is a JDesktopPane, it should
- * delegate most of its behavior to the desktopManager (closing, resizing, etc).
- * <p>
- * Warning: serialized objects of this class will not be compatible with
- * future swing releases. The current serialization support is appropriate
- * for short term storage or RMI between Swing1.0 applications. It will
- * not be possible to load serialized Swing1.0 objects with future releases
- * of Swing. The JDK1.2 release of Swing will be the compatibility
- * baseline for the serialized form of Swing objects.
- *
- * @see JInternalFrame
- * @see JInternalFrame.JDesktopIcon
- * @see DesktopManager
- *
- * @version 1.14 02/06/98
- * @author David Kloba
- */
- public class JDesktopPane extends JLayeredPane implements Accessible
- {
- DesktopManager desktopManager;
-
- public JDesktopPane() {
- updateUI();
- }
-
- public DesktopPaneUI getUI() {
- return (DesktopPaneUI)ui;
- }
-
- public void setUI(DesktopPaneUI ui) {
- super.setUI(ui);
- }
-
- public DesktopManager getDesktopManager() {
- return desktopManager;
- }
-
- public void setDesktopManager(DesktopManager d) {
- desktopManager = d;
- }
-
- /**
- * Called to replace the UI with the latest version from the
- * default UIFactory.
- */
- public void updateUI() {
- setUI((DesktopPaneUI)UIManager.getUI(this));
- }
-
-
- /**
- * @return "DesktopPaneUI"
- * @see JComponent#getUIClassID
- * @see UIDefaults#getUI
- */
- public String getUIClassID() {
- return "DesktopPaneUI";
- }
-
-
-
- /** Returns all JInternalFrames currently displayed in the
- * desktop. This will return iconified frames as well.
- */
- public JInternalFrame[] getAllFrames() {
- int i, count;
- JInternalFrame[] results;
- Vector vResults = new Vector(10);
- Object next, tmp;
-
- count = getComponentCount();
- for(i = 0; i < count; i++) {
- next = getComponent(i);
- if(next instanceof JInternalFrame)
- vResults.addElement(next);
- else if(next instanceof JInternalFrame.JDesktopIcon) {
- tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
- if(tmp != null)
- vResults.addElement(tmp);
- }
- }
-
- results = new JInternalFrame[vResults.size()];
- vResults.copyInto(results);
-
- return results;
- }
-
- /** Returns all JInternalFrames currently displayed in the
- * desktop that are in <b>layer</b>. This will return iconified frames as well.
- */
- public JInternalFrame[] getAllFramesInLayer(int layer) {
- int i, count;
- JInternalFrame[] results;
- Vector vResults = new Vector(10);
- Object next, tmp;
-
- count = getComponentCount();
- for(i = 0; i < count; i++) {
- next = getComponent(i);
- if(next instanceof JInternalFrame)
- if(((JInternalFrame)next).getLayer() == layer)
- vResults.addElement(next);
- else if(next instanceof JInternalFrame.JDesktopIcon) {
- tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
- if(tmp != null && ((JInternalFrame)tmp).getLayer() == layer)
- vResults.addElement(tmp);
- }
- }
-
- results = new JInternalFrame[vResults.size()];
- vResults.copyInto(results);
-
- return results;
- }
-
- public boolean isOpaque() {
- return true;
- }
-
- /////////////////
- // Accessibility support
- ////////////////
-
- /**
- * Get the AccessibleContext associated with this JComponent
- *
- * @return the AccessibleContext of this JComponent
- */
- public AccessibleContext getAccessibleContext() {
- if (accessibleContext == null) {
- accessibleContext = new AccessibleJDesktopPane();
- }
- return accessibleContext;
- }
-
- /**
- * The class used to obtain the accessible role for this object.
- * <p>
- * Warning: serialized objects of this class will not be compatible with
- * future swing releases. The current serialization support is appropriate
- * for short term storage or RMI between Swing1.0 applications. It will
- * not be possible to load serialized Swing1.0 objects with future releases
- * of Swing. The JDK1.2 release of Swing will be the compatibility
- * baseline for the serialized form of Swing objects.
- */
- protected class AccessibleJDesktopPane extends AccessibleJComponent {
-
- /**
- * Get the role of this object.
- *
- * @return an instance of AccessibleRole describing the role of the
- * object
- * @see AccessibleRole
- */
- public AccessibleRole getAccessibleRole() {
- return AccessibleRole.DESKTOP_PANE;
- }
- }
- }
-
-