Hi,
A testcase that I committed to Mauve showed a bug in
JLayeredPane.getComponentsInLayer. This method should return an empty
array for unknown layers instead of throwing an exception. This is fixed.
2005-11-08 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/JLayeredPane.java
(layerToRange): Return empty array for unknown layer instead of
throwing an exception.
/Roman
Index: javax/swing/JLayeredPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JLayeredPane.java,v
retrieving revision 1.31
diff -u -r1.31 JLayeredPane.java
--- javax/swing/JLayeredPane.java 25 Oct 2005 13:49:47 -0000 1.31
+++ javax/swing/JLayeredPane.java 8 Nov 2005 12:17:49 -0000
@@ -250,22 +250,30 @@
ret[1] = getComponents ().length;
Iterator i = layers.entrySet ().iterator ();
while (i.hasNext())
- {
+ {
Map.Entry pair = (Map.Entry) i.next();
Integer layerNum = (Integer) pair.getKey ();
Integer layerSz = (Integer) pair.getValue ();
- if (layerNum.intValue() == layer.intValue())
+ int layerInt = layerNum.intValue();
+ if (layerInt == layer.intValue())
{
ret[0] = ret[1] - layerSz.intValue ();
- return ret;
+ break;
+ }
+ // In the following case there exists no layer with the specified
+ // number, so we return an empty interval here with the index at which
+ // such a layer would be inserted
+ else if (layerInt > layer.intValue())
+ {
+ ret[1] = ret[0];
+ break;
}
else
{
ret[1] -= layerSz.intValue ();
}
- }
- // should have found the layer during iteration
- throw new IllegalArgumentException ();
+ }
+ return ret;
}
/**
@@ -629,7 +637,7 @@
* @param index an ignored parameter, for compatibility.
*/
protected void addImpl(Component comp, Object layerConstraint, int index)
- {
+ {
Integer layer;
if (layerConstraint != null && layerConstraint instanceof Integer)
layer = (Integer) layerConstraint;
@@ -643,8 +651,8 @@
componentToLayer.put (comp, layer);
incrLayer (layer);
- super.addImpl(comp, null, newIdx);
- }
+ super.addImpl(comp, null, newIdx);
+ }
/**
* Sets the layer property for a JComponent.
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches