I'm requesting approval for this patch that implements six methods in java.awt.Component that were added in JDK1.5:

2006-06-16  David Gilbert  <[EMAIL PROTECTED]>

        * java/awt/Component.java
        (minSizeSet): New field,
        (maxSize): Likewise,
        (maxSizeSet): Likewise,
        (isMaximumSizeSet): Implemented,
        (isMinimumSizeSet): Likewise,
        (isPreferredSizeSet): Likewise,
        (setMaximumSize): Likewise,
        (setMinimumSize): Likewise,
        (setPreferredSize): Likewise.

I'm asking for approval because Component is a core class in AWT and I don't like to change those without asking first. Having said that, it is an easy patch to revert if necessary...

Regards,

Dave
Index: java/awt/Component.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.124
diff -u -r1.124 Component.java
--- java/awt/Component.java     14 Jun 2006 19:09:40 -0000      1.124
+++ java/awt/Component.java     16 Jun 2006 09:46:55 -0000
@@ -70,6 +70,7 @@
 import java.awt.image.VolatileImage;
 import java.awt.peer.ComponentPeer;
 import java.awt.peer.LightweightPeer;
+import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.IOException;
@@ -427,6 +428,24 @@
   Dimension minSize;
 
   /**
+   * Flag indicating whether the minimum size for the component has been set
+   * by a call to [EMAIL PROTECTED] #setMinimumSize(Dimension)} with a 
non-null value.
+   */
+  boolean minSizeSet;
+  
+  /**
+   * The maximum size for the component.
+   * @see #setMaximumSize(Dimension)
+   */
+  Dimension maxSize;
+  
+  /**
+   * A flag indicating whether the maximum size for the component has been set
+   * by a call to [EMAIL PROTECTED] #setMaximumSize(Dimension)} with a 
non-null value.
+   */
+  boolean maxSizeSet;
+  
+  /**
    * Cached information on the preferred size. Should have been transient.
    *
    * @serial ignore
@@ -434,6 +453,12 @@
   Dimension prefSize;
 
   /**
+   * Flag indicating whether the preferred size for the component has been set
+   * by a call to [EMAIL PROTECTED] #setPreferredSize(Dimension)} with a 
non-null value.
+   */
+  boolean prefSizeSet;
+
+  /**
    * Set to true if an event is to be handled by this component, false if
    * it is to be passed up the hierarcy.
    *
@@ -1584,6 +1609,7 @@
    *
    * @return the component's preferred size
    * @see #getMinimumSize()
+   * @see #setPreferredSize(Dimension)
    * @see LayoutManager
    */
   public Dimension getPreferredSize()
@@ -1592,6 +1618,40 @@
   }
 
   /**
+   * Sets the preferred size that will be returned by 
+   * [EMAIL PROTECTED] #getPreferredSize()} always, and sends a 
+   * [EMAIL PROTECTED] PropertyChangeEvent} (with the property name 
'preferredSize') to 
+   * all registered listeners.
+   * 
+   * @param size  the preferred size (<code>null</code> permitted).
+   * 
+   * @since 1.5
+   * 
+   * @see #getPreferredSize()
+   */
+  public void setPreferredSize(Dimension size)
+  {
+    Dimension old = prefSizeSet ? prefSize : null;
+    prefSize = size;
+    prefSizeSet = (size != null);
+    firePropertyChange("preferredSize", old, size);
+  }
+  
+  /**
+   * Returns <code>true</code> if the current preferred size is not 
+   * <code>null</code> and was set by a call to 
+   * [EMAIL PROTECTED] #setPreferredSize(Dimension)}, otherwise returns 
<code>false</code>.
+   * 
+   * @return A boolean.
+   * 
+   * @since 1.5
+   */
+  public boolean isPreferredSizeSet()
+  {
+    return prefSizeSet;
+  }
+  
+  /**
    * Returns the component's preferred size.
    *
    * @return the component's preferred size
@@ -1614,6 +1674,7 @@
    * 
    * @return the component's minimum size
    * @see #getPreferredSize()
+   * @see #setMinimumSize(Dimension)
    * @see LayoutManager
    */
   public Dimension getMinimumSize()
@@ -1622,6 +1683,39 @@
   }
 
   /**
+   * Sets the minimum size that will be returned by [EMAIL PROTECTED] 
#getMinimumSize()}
+   * always, and sends a [EMAIL PROTECTED] PropertyChangeEvent} (with the 
property name
+   * 'minimumSize') to all registered listeners.
+   * 
+   * @param size  the minimum size (<code>null</code> permitted).
+   * 
+   * @since 1.5
+   * 
+   * @see #getMinimumSize()
+   */
+  public void setMinimumSize(Dimension size)
+  {
+    Dimension old = minSizeSet ? minSize : null;
+    minSize = size;
+    minSizeSet = (size != null);
+    firePropertyChange("minimumSize", old, size);
+  }
+  
+  /**
+   * Returns <code>true</code> if the current minimum size is not 
+   * <code>null</code> and was set by a call to 
+   * [EMAIL PROTECTED] #setMinimumSize(Dimension)}, otherwise returns 
<code>false</code>.
+   * 
+   * @return A boolean.
+   * 
+   * @since 1.5
+   */
+  public boolean isMinimumSizeSet()
+  {
+    return minSizeSet;
+  }
+  
+  /**
    * Returns the component's minimum size.
    *
    * @return the component's minimum size
@@ -1640,15 +1734,52 @@
    *
    * @return the component's maximum size
    * @see #getMinimumSize()
+   * @see #setMaximumSize(Dimension)
    * @see #getPreferredSize()
    * @see LayoutManager
    */
   public Dimension getMaximumSize()
   {
-    return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+    if (maxSizeSet)
+      return maxSize;
+    else
+      return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
   }
 
   /**
+   * Sets the maximum size that will be returned by [EMAIL PROTECTED] 
#getMaximumSize()}
+   * always, and sends a [EMAIL PROTECTED] PropertyChangeEvent} (with the 
property name
+   * 'maximumSize') to all registered listeners.
+   * 
+   * @param size  the maximum size (<code>null</code> permitted).
+   * 
+   * @since 1.5
+   * 
+   * @see #getMaximumSize()
+   */
+  public void setMaximumSize(Dimension size)
+  {
+    Dimension old = maxSizeSet ? maxSize : null;
+    maxSize = size;
+    maxSizeSet = (size != null);
+    firePropertyChange("maximumSize", old, size);
+  }
+
+  /**
+   * Returns <code>true</code> if the current maximum size is not 
+   * <code>null</code> and was set by a call to 
+   * [EMAIL PROTECTED] #setMaximumSize(Dimension)}, otherwise returns 
<code>false</code>.
+   * 
+   * @return A boolean.
+   * 
+   * @since 1.5
+   */
+  public boolean isMaximumSizeSet()
+  {
+    return maxSizeSet;
+  }
+  
+  /**
    * Returns the preferred horizontal alignment of this component. The value
    * returned will be between [EMAIL PROTECTED] #LEFT_ALIGNMENT} and
    * [EMAIL PROTECTED] #RIGHT_ALIGNMENT}, inclusive.

Reply via email to