I fixed one more JLayeredPane algorithm mistake, this makes the
corresponding Mauve test pass.

2006-01-31  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JLayeredPane.java
        (insertIndexForLayer): Fixed algorithm to correctly determine
        inser index for positions >= 0.
        (addImpl): Fixed API docs for the index parameter.

/Roman
Index: javax/swing/JLayeredPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JLayeredPane.java,v
retrieving revision 1.41
diff -u -r1.41 JLayeredPane.java
--- javax/swing/JLayeredPane.java	30 Jan 2006 13:09:07 -0000	1.41
+++ javax/swing/JLayeredPane.java	1 Feb 2006 12:15:07 -0000
@@ -495,6 +495,10 @@
    */
   protected int insertIndexForLayer(int layer, int position)
   {
+    // position < 0 means insert at greatest position within layer.
+    if (position < 0)
+      position = Integer.MAX_VALUE;
+
     Component[] components = getComponents();
     int index = 0;
 
@@ -509,7 +513,7 @@
         else if (l == layer)
           {
             p++;
-            if (p >= position)
+            if (p < position)
               index++;
             else
               break;
@@ -580,9 +584,15 @@
    * Integer}, specifying the layer to which the component will be added
    * (at the bottom position).
    *
-   * @param comp the component to add.
-   * @param layerConstraint an integer specifying the layer to add the component to.
-   * @param index an ignored parameter, for compatibility.
+   * The argument <code>index</code> specifies the position within the layer
+   * at which the component should be added, where <code>0</code> is the top
+   * position greater values specify positions below that and <code>-1</code>
+   * specifies the bottom position.
+   *
+   * @param comp the component to add
+   * @param layerConstraint an integer specifying the layer to add the
+   *        component to
+   * @param index the position within the layer
    */
   protected void addImpl(Component comp, Object layerConstraint, int index) 
   {

Reply via email to