aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/JInternalFrame.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/JInternalFrame.java')
-rw-r--r--libjava/classpath/javax/swing/JInternalFrame.java266
1 files changed, 171 insertions, 95 deletions
diff --git a/libjava/classpath/javax/swing/JInternalFrame.java b/libjava/classpath/javax/swing/JInternalFrame.java
index 5bd6f78..79dcc73 100644
--- a/libjava/classpath/javax/swing/JInternalFrame.java
+++ b/libjava/classpath/javax/swing/JInternalFrame.java
@@ -1,5 +1,5 @@
/* JInternalFrame.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,6 +44,7 @@ import java.awt.Graphics;
import java.awt.KeyboardFocusManager;
import java.awt.LayoutManager;
import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import javax.accessibility.Accessible;
@@ -67,11 +68,12 @@ public class JInternalFrame extends JComponent implements Accessible,
WindowConstants,
RootPaneContainer
{
- /** DOCUMENT ME! */
+
private static final long serialVersionUID = -5425177187760785402L;
/**
- * DOCUMENT ME!
+ * Provides the accessibility features for the <code>JInternalFrame</code>
+ * component.
*/
protected class AccessibleJInternalFrame extends AccessibleJComponent
implements AccessibleValue
@@ -79,7 +81,7 @@ public class JInternalFrame extends JComponent implements Accessible,
private static final long serialVersionUID = 5931936924175476797L;
/**
- * Creates a new AccessibleJInternalFrame object.
+ * Creates a new <code>AccessibleJInternalFrame</code> instance.
*/
protected AccessibleJInternalFrame()
{
@@ -87,75 +89,83 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * DOCUMENT ME!
+ * Returns the frame title.
*
- * @return DOCUMENT ME!
+ * @return The frame title.
*/
public String getAccessibleName()
{
- return null;
+ return getTitle();
}
/**
- * DOCUMENT ME!
+ * Returns the accessible role for the <code>JInternalFrame</code>
+ * component.
*
- * @return DOCUMENT ME!
+ * @return {@link AccessibleRole#INTERNAL_FRAME}.
*/
public AccessibleRole getAccessibleRole()
{
- return null;
+ return AccessibleRole.INTERNAL_FRAME;
}
/**
- * DOCUMENT ME!
+ * Returns an object that provides access to the current, minimum and
+ * maximum values for the {@link JInternalFrame}. Since this class
+ * implements {@link AccessibleValue}, it returns itself.
*
- * @return DOCUMENT ME!
+ * @return The accessible value.
*/
public AccessibleValue getAccessibleValue()
{
- return null;
+ return this;
}
/**
- * DOCUMENT ME!
+ * Returns the current layer for the {@link JInternalFrame} component,
+ * as an {@link Integer}.
*
- * @return DOCUMENT ME!
+ * @return The layer for the {@link JInternalFrame} component.
*/
public Number getCurrentAccessibleValue()
{
- return null;
+ return new Integer(getLayer());
}
/**
- * DOCUMENT ME!
+ * Returns the maximum permitted accessible value.
*
- * @return DOCUMENT ME!
+ * @return <code>Integer(Integer.MAX_VALUE)</code>.
*/
public Number getMaximumAccessibleValue()
{
- return null;
+ return new Integer(Integer.MAX_VALUE);
}
/**
- * DOCUMENT ME!
+ * Returns the minimum permitted accessible value.
*
- * @return DOCUMENT ME!
+ * @return <code>Integer(Integer.MIN_VALUE)</code>.
*/
public Number getMinimumAccessibleValue()
{
- return null;
+ return new Integer(Integer.MIN_VALUE);
}
/**
- * DOCUMENT ME!
+ * Sets the layer for the internal frame.
*
- * @param n DOCUMENT ME!
+ * @param n the layer (see the constants defined in {@link JLayeredPane}).
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the value is set, and <code>false</code>
+ * if it was not set.
*/
public boolean setCurrentAccessibleValue(Number n)
{
- return false;
+ if (n == null)
+ return false;
+ setLayer(n.intValue());
+ return true;
}
}
@@ -165,7 +175,8 @@ public class JInternalFrame extends JComponent implements Accessible,
public static class JDesktopIcon extends JComponent implements Accessible
{
/**
- * DOCUMENT ME!
+ * Provides the accessibility features for the <code>JDesktopIcon</code>
+ * component.
*/
protected class AccessibleJDesktopIcon extends AccessibleJComponent
implements AccessibleValue
@@ -173,73 +184,83 @@ public class JInternalFrame extends JComponent implements Accessible,
private static final long serialVersionUID = 5035560458941637802L;
/**
- * Creates a new AccessibleJDesktopIcon object.
+ * Creates a new <code>AccessibleJDesktopIcon</code> instance.
*/
protected AccessibleJDesktopIcon()
{
- super();
+ super();
}
/**
- * DOCUMENT ME!
+ * Returns the accessible role for the <code>JDesktopIcon</code>
+ * component.
*
- * @return DOCUMENT ME!
+ * @return {@link AccessibleRole#DESKTOP_ICON}.
*/
public AccessibleRole getAccessibleRole()
{
- return null;
+ return AccessibleRole.DESKTOP_ICON;
}
/**
- * DOCUMENT ME!
+ * Returns an object that provides access to the current, minimum and
+ * maximum values for the {@link JDesktopIcon}. Since this class
+ * implements {@link AccessibleValue}, it returns itself.
*
- * @return DOCUMENT ME!
+ * @return The accessible value.
*/
public AccessibleValue getAccessibleValue()
{
- return null;
+ return this;
}
/**
- * DOCUMENT ME!
+ * Returns the current layer for the {@link JInternalFrame} component
+ * represented by this <code>JDesktopIcon</code>, as an {@link Integer}.
*
- * @return DOCUMENT ME!
+ * @return The layer.
*/
public Number getCurrentAccessibleValue()
{
- return null;
+ return new Integer(frame.getLayer());
}
/**
- * DOCUMENT ME!
+ * Returns the maximum permitted accessible value.
*
- * @return DOCUMENT ME!
+ * @return <code>Integer(Integer.MAX_VALUE)</code>.
*/
public Number getMaximumAccessibleValue()
{
- return null;
+ return new Integer(Integer.MAX_VALUE);
}
/**
- * DOCUMENT ME!
+ * Returns the minimum permitted accessible value.
*
- * @return DOCUMENT ME!
+ * @return <code>Integer(Integer.MIN_VALUE)</code>.
*/
public Number getMinimumAccessibleValue()
{
- return null;
+ return new Integer(Integer.MIN_VALUE);
}
/**
- * DOCUMENT ME!
+ * Sets the layer for the internal frame represented by this
+ * <code>JDesktopIcon</code> component.
*
- * @param n DOCUMENT ME!
+ * @param n the layer (see the constants defined in
+ * {@link JLayeredPane}).
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the value is set, and <code>false</code>
+ * if it was not set.
*/
public boolean setCurrentAccessibleValue(Number n)
{
- return false;
+ if (n == null)
+ return false;
+ frame.setLayer(n.intValue());
+ return true;
}
}
@@ -259,15 +280,17 @@ public class JInternalFrame extends JComponent implements Accessible,
updateUI();
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
+ /**
+ * Returns the object that provides accessibility features for this
+ * <code>JDesktopIcon</code> component.
+ *
+ * @return The accessible context (an instance of
+ * {@link AccessibleJDesktopIcon}).
+ */
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
- accessibleContext = new AccessibleJDesktopIcon();
+ accessibleContext = new AccessibleJDesktopIcon();
return accessibleContext;
}
@@ -477,12 +500,13 @@ public class JInternalFrame extends JComponent implements Accessible,
private transient boolean wasIcon = false;
/**
- * Creates a new JInternalFrame object that has no title, and is
- * non-resizable, non-maximizable, non-iconifiable, and non-closable.
+ * Creates a new JInternalFrame object that has an empty string for its
+ * title, and is non-resizable, non-maximizable, non-iconifiable, and
+ * non-closable.
*/
public JInternalFrame()
{
- this(null, false, false, false, false);
+ this("", false, false, false, false);
}
/**
@@ -559,8 +583,9 @@ public class JInternalFrame extends JComponent implements Accessible,
this.iconable = iconifiable;
storedBounds = new Rectangle();
setRootPane(createRootPane());
- // JInternalFrames are invisible by default.
+ // JInternalFrames are invisible and opaque by default.
setVisible(false);
+ setOpaque(true);
updateUI();
setRootPaneCheckingEnabled(true); // Done the init stage, now adds go to content pane.
}
@@ -726,9 +751,11 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * DOCUMENT ME!
+ * Returns the object that provides accessibility features for this
+ * <code>JInternalFrame</code> component.
*
- * @return DOCUMENT ME!
+ * @return The accessible context (an instance of
+ * {@link AccessibleJInternalFrame}).
*/
public AccessibleContext getAccessibleContext()
{
@@ -748,10 +775,16 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method returns the default action taken when this JInternalFrame is
- * closed.
+ * Returns a code for the default action taken when this
+ * <code>JInternalFrame</code> is closed.
*
- * @return The default action taken when this JInternalFrame is closed.
+ * @return The action code (usually one of
+ * {@link WindowConstants#DO_NOTHING_ON_CLOSE},
+ * {@link WindowConstants#HIDE_ON_CLOSE}, or
+ * {@link WindowConstants#DISPOSE_ON_CLOSE}).
+ *
+ * @see #setDefaultCloseOperation(int)
+ * @see #doDefaultCloseAction()
*/
public int getDefaultCloseOperation()
{
@@ -759,11 +792,10 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method returns the JDesktopIcon that represents this JInternalFrame
- * while it is iconified.
+ * Returns the <code>JDesktopIcon</code> that represents this
+ * <code>JInternalFrame</code> while it is iconified.
*
- * @return The JDesktopIcon that represents this JInternalFrame while it is
- * iconified.
+ * @return The desktop icon component.
*/
public JDesktopIcon getDesktopIcon()
{
@@ -878,7 +910,12 @@ public class JInternalFrame extends JComponent implements Accessible,
// instead of the static method (this would lead to infinite
// recursion).
return pane.getLayer((Component) this);
- return -1;
+
+ Integer layer = (Integer) getClientProperty(JLayeredPane.LAYER_PROPERTY);
+ if (layer != null)
+ return layer.intValue();
+
+ return JLayeredPane.DEFAULT_LAYER.intValue();
}
/**
@@ -950,9 +987,11 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method sets the title of the JInternalFrame.
+ * Returns the frame's title.
*
- * @return The String displayed in the TitlePane of this JInternalFrame.
+ * @return The frame's title (can be <code>null</code>).
+ *
+ * @see #setTitle(String)
*/
public String getTitle()
{
@@ -1171,13 +1210,15 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method returns a String describing this JInternalFrame.
+ * An implementation dependent string describing the current state of this
+ * <code>JInternalFrame</code> instance.
*
- * @return A String describing this JInternalFrame.
+ * @return A string describing the current state of this
+ * <code>JInternalFrame</code> instance.
*/
protected String paramString()
{
- return super.paramString();
+ return super.paramString() + ",title=" + getTitle();
}
/**
@@ -1189,7 +1230,7 @@ public class JInternalFrame extends JComponent implements Accessible,
{
// If we're removing the root pane, use super.remove. Otherwise
// pass it on to the content pane instead.
- if (comp==rootPane)
+ if (comp==rootPane || ! isRootPaneCheckingEnabled())
super.remove(comp);
else
getContentPane().remove(comp);
@@ -1238,7 +1279,11 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setClosable(boolean b)
{
- closable = b;
+ if (closable != b)
+ {
+ closable = b;
+ firePropertyChange("closable", ! closable, closable);
+ }
}
/**
@@ -1287,12 +1332,17 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method sets the action taken when this JInternalFrame is closed.
+ * Sets a code for the action to be taken when this
+ * <code>JInternalFrame</code> is closed. Note that no validation is
+ * performed on the <code>operation</code> code, any integer will be
+ * accepted (nevertheless, you should pass in one of the listed values).
*
- * @param operation One of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE or
- * DISPOSE_ON_CLOSE.
- *
- * @throws Error If the given operation is not one of the allowed modes.
+ * @param operation one of {@link WindowConstants#DO_NOTHING_ON_CLOSE},
+ * {@link WindowConstants#HIDE_ON_CLOSE} or
+ * {@link WindowConstants#DISPOSE_ON_CLOSE}.
+ *
+ * @see #getDefaultCloseOperation()
+ * @see #doDefaultCloseAction()
*/
public void setDefaultCloseOperation(int operation)
{
@@ -1304,16 +1354,24 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method sets the JDesktopIcon that represents this JInternalFrame
- * while it is iconified.
+ * Sets the <code>JDesktopIcon</code> instance that represents this
+ * <code>JInternalFrame</code> while it is iconified and, if the new icon is
+ * not the same instance as the existing icon, sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * <code>"desktopIcon"</code>) to all registered listeners..
*
- * @param d The JDesktopIcon that represents this JInternalFrame while it is
- * iconified.
+ * @param d the icon.
+ *
+ * @see #getDesktopIcon()
*/
public void setDesktopIcon(JDesktopIcon d)
{
- d.setInternalFrame(this);
- desktopIcon = d;
+ if (desktopIcon != d)
+ {
+ JDesktopIcon oldIcon = desktopIcon;
+ desktopIcon = d;
+ firePropertyChange("desktopIcon", oldIcon, d);
+ }
}
/**
@@ -1396,7 +1454,11 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setIconifiable(boolean b)
{
- iconable = b;
+ if (iconable != b)
+ {
+ iconable = b;
+ firePropertyChange("iconable", ! iconable, iconable);
+ }
}
/**
@@ -1461,7 +1523,11 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setMaximizable(boolean b)
{
- maximizable = b;
+ if (maximizable != b)
+ {
+ maximizable = b;
+ firePropertyChange("maximizable", ! maximizable, maximizable);
+ }
}
/**
@@ -1538,7 +1604,11 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setResizable(boolean b)
{
- resizable = b;
+ if (b != resizable)
+ {
+ resizable = b;
+ firePropertyChange("resizable", ! resizable, resizable);
+ }
}
/**
@@ -1594,6 +1664,9 @@ public class JInternalFrame extends JComponent implements Accessible,
if (selected)
restoreSubcomponentFocus();
+ if (isShowing())
+ repaint();
+
firePropertyChange(IS_SELECTED_PROPERTY, ! isSelected, isSelected);
if (isSelected)
@@ -1604,10 +1677,13 @@ public class JInternalFrame extends JComponent implements Accessible,
}
/**
- * This method sets the title displayed in the TitlePane of this
- * JInternalFrame.
+ * Sets the title for the <code>JInternalFrame</code> and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #TITLE_PROPERTY}) to all registered listeners.
*
- * @param title The title displayed.
+ * @param title the new title (<code>null</code> permitted).
+ *
+ * @see #getTitle()
*/
public void setTitle(String title)
{
@@ -1615,9 +1691,9 @@ public class JInternalFrame extends JComponent implements Accessible,
return;
if (title == null || this.title == null || ! this.title.equals(title))
{
- String old = title;
- this.title = title;
- firePropertyChange(TITLE_PROPERTY, old, this.title);
+ String old = this.title;
+ this.title = title;
+ firePropertyChange(TITLE_PROPERTY, old, this.title);
}
}