OSDN Git Service

Imported GNU Classpath 0.90
[pf3gnuchains/gcc-fork.git] / libjava / classpath / javax / swing / JDesktopPane.java
index 43ab71e..454870e 100644 (file)
@@ -56,7 +56,6 @@ import javax.swing.plaf.DesktopPaneUI;
  */
 public class JDesktopPane extends JLayeredPane implements Accessible
 {
-  /** DOCUMENT ME! */
   private static final long serialVersionUID = 766333777224038726L;
 
   /**
@@ -85,15 +84,24 @@ public class JDesktopPane extends JLayeredPane implements Accessible
   private transient int dragMode = LIVE_DRAG_MODE;
 
   /**
-   * AccessibleJDesktopPane
+   * Indicates if the dragMode property has been set by a client
+   * program or by the UI.
+   *
+   * @see #setUIProperty(String, Object)
+   * @see LookAndFeel#installProperty(JComponent, String, Object)
+   */
+  private boolean clientDragModeSet = false;
+
+  /**
+   * Provides the accessibility features for the <code>JDesktopPane</code>
+   * component.
    */
   protected class AccessibleJDesktopPane extends AccessibleJComponent
   {
-    /** DOCUMENT ME! */
     private static final long serialVersionUID = 6079388927946077570L;
 
     /**
-     * Constructor AccessibleJDesktopPane
+     * Creates a new <code>AccessibleJDesktopPane</code> instance.
      */
     protected AccessibleJDesktopPane()
     {
@@ -101,9 +109,9 @@ public class JDesktopPane extends JLayeredPane implements Accessible
     }
 
     /**
-     * getAccessibleRole
+     * Returns the accessible role for the <code>JSlider</code> component.
      *
-     * @return AccessibleRole
+     * @return {@link AccessibleRole#DESKTOP_PANE}.
      */
     public AccessibleRole getAccessibleRole()
     {
@@ -153,6 +161,8 @@ public class JDesktopPane extends JLayeredPane implements Accessible
     if ((mode != LIVE_DRAG_MODE) && (mode != OUTLINE_DRAG_MODE))
       throw new IllegalArgumentException("Drag mode not valid.");
 
+    clientDragModeSet = true;
+
     // FIXME: Unsupported mode.
     if (mode == OUTLINE_DRAG_MODE)
       // throw new IllegalArgumentException("Outline drag modes are
@@ -198,7 +208,6 @@ public class JDesktopPane extends JLayeredPane implements Accessible
   public void updateUI()
   {
     setUI((DesktopPaneUI) UIManager.getUI(this));
-    invalidate();
   }
 
   /**
@@ -288,13 +297,22 @@ public class JDesktopPane extends JLayeredPane implements Accessible
   }
 
   /**
-   * This method returns a String that describes the JDesktopPane.
+   * Returns an implementation-dependent string describing the attributes of
+   * this <code>JDesktopPane</code>.
    *
-   * @return A String that describes the JDesktopPane.
+   * @return A string describing the attributes of this <code>JDesktopPane</code>
+   *         (never <code>null</code>).
    */
   protected String paramString()
   {
-    return "JDesktopPane";
+    String superParamStr = super.paramString();
+    StringBuffer sb = new StringBuffer();
+    sb.append(",isOptimizedDrawingPossible=");
+    sb.append(isOptimizedDrawingEnabled());
+    sb.append(",desktopManager=");
+    if (desktopManager != null)
+      sb.append(desktopManager);
+    return superParamStr + sb.toString();
   }
 
   /**
@@ -320,9 +338,11 @@ public class JDesktopPane extends JLayeredPane implements Accessible
   }
 
   /**
-   * getAccessibleContext
+   * Returns the object that provides accessibility features for this
+   * <code>JDesktopPane</code> component.
    *
-   * @return AccessibleContext
+   * @return The accessible context (an instance of 
+   *     {@link AccessibleJDesktopPane}).
    */
   public AccessibleContext getAccessibleContext()
   {
@@ -331,4 +351,34 @@ public class JDesktopPane extends JLayeredPane implements Accessible
 
     return accessibleContext;
   }
+
+  /**
+   * Helper method for
+   * {@link LookAndFeel#installProperty(JComponent, String, Object)}.
+   * 
+   * @param propertyName the name of the property
+   * @param value the value of the property
+   *
+   * @throws IllegalArgumentException if the specified property cannot be set
+   *         by this method
+   * @throws ClassCastException if the property value does not match the
+   *         property type
+   * @throws NullPointerException if <code>c</code> or
+   *         <code>propertyValue</code> is <code>null</code>
+   */
+  void setUIProperty(String propertyName, Object value)
+  {
+    if (propertyName.equals("dragMode"))
+      {
+        if (! clientDragModeSet)
+          {
+            setDragMode(((Integer) value).intValue());
+            clientDragModeSet = false;
+          }
+      }
+    else
+      {
+        super.setUIProperty(propertyName, value);
+      }
+  }
 }