This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui][patch] fix for bug 16576
- From: "graydon hoare" <graydon at redhat dot com>
- To: "java-patches.gcc.gnu.org" <java-patches at gcc dot gnu dot org>
- Date: Wed, 04 Aug 2004 00:57:40 -0400
- Subject: [gui][patch] fix for bug 16576
- Organization: red hat
hi,
this patch fixes some bugs in the layered pane, and also throws in
a minor improvement to Box.java, which was used by one of the
layered pane demos in the swing tutorial. this is in response to
PR SWING/16576.
committed to java-gui-branch.
-graydon
2004-08-03 Graydon Hoare <graydon@redhat.com>
PR SWING/16576
* javax/swing/JLayeredPane.java
(setLayer): Permit changing layer after addition.
(setPosition): Permit over-length positions.
(layerToRange): Compare intValue()s.
* javax/swing/Box.java (createHorizontalBox): Implement.
(createRigidArea): Likewise.
(createVerticalBox): Likewise.
--- javax/swing/Box.java 30 Jul 2004 21:34:34 -0000 1.3.2.9
+++ javax/swing/Box.java 4 Aug 2004 04:15:34 -0000
@@ -198,7 +198,7 @@
public static Box createHorizontalBox()
{
- return null;
+ return new Box(BoxLayout.X_AXIS);
}
/**
@@ -231,12 +231,12 @@
public static Component createRigidArea(Dimension d)
{
- return null;
+ return new Filler(d, d, d);
}
public static Box createVerticalBox()
{
- return null;
+ return new Box(BoxLayout.Y_AXIS);
}
/**
--- javax/swing/JLayeredPane.java 14 Jun 2004 14:16:57 -0000 1.6.8.4
+++ javax/swing/JLayeredPane.java 4 Aug 2004 04:15:35 -0000
@@ -153,7 +153,7 @@
Map.Entry pair = (Map.Entry) i.next();
Integer layerNum = (Integer) pair.getKey ();
Integer layerSz = (Integer) pair.getValue ();
- if (layerNum == layer)
+ if (layerNum.intValue() == layer.intValue())
{
ret[0] = ret[1] - layerSz.intValue ();
return ret;
@@ -314,7 +314,7 @@
int bot = range[1];
if (position == -1)
position = (bot - top) - 1;
- int targ = top + position;
+ int targ = Math.min(top + position, bot-1);
int curr = -1;
Component[] comps = getComponents();
@@ -539,7 +539,8 @@
int layer,
int position)
{
- componentToLayer.put (c, getObjectForLayer (layer));
+ remove(c);
+ add(c, getObjectForLayer (layer));
setPosition(c, position);
revalidate();
repaint();