/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.accessibility.*;
/**
* A container used to create a multiple-document interface or a virtual desktop.
* You create <code>JInternalFrame</code> objects and add them to the
* <code>JDesktopPane</code>. <code>JDesktopPane</code> extends
* <code>JLayeredPane</code> to manage the potentially overlapping internal
* frames. It also maintains a reference to an instance of
* <code>DesktopManager</code> that is set by the UI
* class for the current look and feel (L&F). Note that <code>JDesktopPane</code>
* does not support borders.
* <p>
* This class is normally used as the parent of <code>JInternalFrames</code>
* to provide a pluggable <code>DesktopManager</code> object to the
* <code>JInternalFrames</code>. The <code>installUI</code> of the
* L&F specific implementation is responsible for setting the
* <code>desktopManager</code> variable appropriately.
* When the parent of a <code>JInternalFrame</code> is a <code>JDesktopPane</code>,
* it should delegate most of its behavior to the <code>desktopManager</code>
* (closing, resizing, etc).
* <p>
* For further documentation and examples see
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html">How to Use Internal Frames</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
* <strong>Warning:</strong> Swing is not thread safe. For more
* information see <a
* href="package-summary.html#threading">Swing's Threading
* Policy</a>.
* <p>
* <strong>Warning:</strong>
* 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 applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see JInternalFrame
* @see JInternalFrame.JDesktopIcon
* @see DesktopManager
*
* @author David Kloba
*/
{
/**
* @see #getUIClassID
* @see #readObject
*/
/**
* Indicates that the entire contents of the item being dragged
* should appear inside the desktop pane.
*
* @see #OUTLINE_DRAG_MODE
* @see #setDragMode
*/
/**
* Indicates that an outline only of the item being dragged
* should appear inside the desktop pane.
*
* @see #LIVE_DRAG_MODE
* @see #setDragMode
*/
private boolean dragModeSet = false;
private boolean componentOrderCheckingEnabled = true;
private boolean componentOrderChanged = false;
/**
* Creates a new <code>JDesktopPane</code>.
*/
public JDesktopPane() {
setFocusCycleRoot(true);
break;
}
}
return comp;
}
});
updateUI();
}
/**
* Returns the L&F object that renders this component.
*
* @return the <code>DesktopPaneUI</code> object that
* renders this component
*/
return (DesktopPaneUI)ui;
}
/**
* Sets the L&F object that renders this component.
*
* @param ui the DesktopPaneUI L&F object
* @see UIDefaults#getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
* description: The UI object that implements the Component's LookAndFeel.
*/
}
/**
* Sets the "dragging style" used by the desktop pane.
* You may want to change to one mode or another for
* performance or aesthetic reasons.
*
* @param dragMode the style of drag to use for items in the Desktop
*
* @see #LIVE_DRAG_MODE
* @see #OUTLINE_DRAG_MODE
*
* @beaninfo
* bound: true
* description: Dragging style for internal frame children.
* enum: LIVE_DRAG_MODE JDesktopPane.LIVE_DRAG_MODE
* OUTLINE_DRAG_MODE JDesktopPane.OUTLINE_DRAG_MODE
* @since 1.3
*/
int oldDragMode = this.dragMode;
dragModeSet = true;
}
/**
* Gets the current "dragging style" used by the desktop pane.
* @return either <code>Live_DRAG_MODE</code> or
* <code>OUTLINE_DRAG_MODE</code>
* @see #setDragMode
* @since 1.3
*/
public int getDragMode() {
return dragMode;
}
/**
* Returns the <code>DesktopManger</code> that handles
* desktop-specific UI actions.
*/
return desktopManager;
}
/**
* Sets the <code>DesktopManger</code> that will handle
* desktop-specific UI actions. This may be overridden by
* {@code LookAndFeel}.
*
* @param d the <code>DesktopManager</code> to use
*
* @beaninfo
* bound: true
* description: Desktop manager to handle the internal frames in the
* desktop pane.
*/
desktopManager = d;
}
/**
* Notification from the <code>UIManager</code> that the L&F has changed.
* Replaces the current UI object with the latest version from the
* <code>UIManager</code>.
*
* @see JComponent#updateUI
*/
public void updateUI() {
}
/**
* Returns the name of the L&F class that renders this component.
*
* @return the string "DesktopPaneUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
return uiClassID;
}
/**
* Returns all <code>JInternalFrames</code> currently displayed in the
* desktop. Returns iconified frames as well as expanded frames.
*
* @return an array of <code>JInternalFrame</code> objects
*/
}
int i, count;
for (i = 0; i < count; i++) {
if (next instanceof JInternalFrame) {
}
}
}
return results;
}
/** Returns the currently active <code>JInternalFrame</code>
* in this <code>JDesktopPane</code>, or <code>null</code>
* if no <code>JInternalFrame</code> is currently active.
*
* @return the currently active <code>JInternalFrame</code> or
* <code>null</code>
* @since 1.3
*/
return selectedFrame;
}
/** Sets the currently active <code>JInternalFrame</code>
* in this <code>JDesktopPane</code>. This method is used to bridge
* the package gap between JDesktopPane and the platform implementation
* code and should not be called directly. To visually select the frame
* the client must call JInternalFrame.setSelected(true) to activate
* the frame.
* @see JInternalFrame#setSelected(boolean)
*
* @param f the internal frame that's currently selected
* @since 1.3
*/
selectedFrame = f;
}
/**
* Returns all <code>JInternalFrames</code> currently displayed in the
* specified layer of the desktop. Returns iconified frames as well
* expanded frames.
*
* @param layer an int specifying the desktop layer
* @return an array of <code>JInternalFrame</code> objects
* @see JLayeredPane
*/
}
}
}
Component c;
for (int i = 0; i < getComponentCount(); i++) {
c = getComponent(i);
if (c instanceof JInternalFrame) {
i));
}
else if (c instanceof JInternalFrame.JDesktopIcon) {
i));
}
}
}
return frames;
}
private static class ComponentPosition implements
private final int layer;
private final int zOrder;
}
if (delta == 0) {
}
return delta;
}
}
if (f == null) {
return getTopInternalFrame();
}
int i = framesCache.indexOf(f);
/* error */
return null;
}
if (forward) {
// navigate to the next frame
if (++i == framesCache.size()) {
/* wrap */
i = 0;
}
}
else {
// navigate to the previous frame
if (--i == -1) {
/* wrap */
}
}
return framesCache.get(i);
}
return getNextFrame(f, true);
}
return null;
}
}
private void updateFramesCache() {
framesCache = getFrames();
}
private void verifyFramesCache() {
// If framesCache is dirty, then recreate it.
if (componentOrderChanged) {
componentOrderChanged = false;
}
}
/**
* {@inheritDoc}
*/
}
/**
* Selects the next <code>JInternalFrame</code> in this desktop pane.
*
* @param forward a boolean indicating which direction to select in;
* <code>true</code> for forward, <code>false</code> for
* backward
* @return the JInternalFrame that was selected or <code>null</code>
* if nothing was selected
* @since 1.6
*/
if (frameToSelect == null) {
return null;
}
// Maintain navigation traversal order until an
// external stack change, such as a click on a frame.
setComponentOrderCheckingEnabled(false);
}
try { frameToSelect.setSelected(true);
} catch (PropertyVetoException pve) {}
return frameToSelect;
}
/*
* Sets whether component order checking is enabled.
* @param enable a boolean value, where <code>true</code> means
* a change in component order will cause a change in the keyboard
* navigation order.
* @since 1.6
*/
}
/**
* {@inheritDoc}
* @since 1.6
*/
if (comp instanceof JInternalFrame ||
componentOrderChanged = true;
}
}
}
/**
* {@inheritDoc}
* @since 1.6
*/
if (comp instanceof JInternalFrame ||
componentOrderChanged = true;
}
}
}
/**
* {@inheritDoc}
* @since 1.6
*/
public void removeAll() {
int count = getComponentCount();
for (int i = 0; i < count; i++) {
if (comp instanceof JInternalFrame ||
componentOrderChanged = true;
break;
}
}
}
super.removeAll();
}
/**
* {@inheritDoc}
* @since 1.6
*/
if (comp instanceof JInternalFrame ||
componentOrderChanged = true;
}
}
}
/**
* See readObject() and writeObject() in JComponent for more
* information about serialization in Swing.
*/
s.defaultWriteObject();
}
}
}
if (propertyName == "dragMode") {
if (!dragModeSet) {
dragModeSet = false;
}
} else {
}
}
/**
* Returns a string representation of this <code>JDesktopPane</code>.
* This method is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
* be <code>null</code>.
*
* @return a string representation of this <code>JDesktopPane</code>
*/
return super.paramString() +
",desktopManager=" + desktopManagerString;
}
/////////////////
// Accessibility support
////////////////
/**
* Gets the <code>AccessibleContext</code> associated with this
* <code>JDesktopPane</code>. For desktop panes, the
* <code>AccessibleContext</code> takes the form of an
* <code>AccessibleJDesktopPane</code>.
* A new <code>AccessibleJDesktopPane</code> instance is created if necessary.
*
* @return an <code>AccessibleJDesktopPane</code> that serves as the
* <code>AccessibleContext</code> of this <code>JDesktopPane</code>
*/
if (accessibleContext == null) {
accessibleContext = new AccessibleJDesktopPane();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the
* <code>JDesktopPane</code> class. It provides an implementation of the
* Java Accessibility API appropriate to desktop pane user-interface
* elements.
* <p>
* <strong>Warning:</strong>
* 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 applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
/**
* Get the role of this object.
*
* @return an instance of AccessibleRole describing the role of the
* object
* @see AccessibleRole
*/
return AccessibleRole.DESKTOP_PANE;
}
}
}