This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui] [PATCH] CardLayout fixes
- From: David Jee <djee at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: 18 Feb 2004 14:51:11 -0500
- Subject: [gui] [PATCH] CardLayout fixes
- Organization:
Hello.
I'm committing the following patch to the java-gui-branch to fix a few
things in CardLayout. I think the ChangeLog entry below is
self-explanatory.
-David Jee
2004-02-18 David Jee <djee@redhat.com>
* java/awt/CardLayout.java
(addLayoutComponent): Show the first component added as the default.
(removeLayoutComponent): After removing, show the next component.
(gotoComponent): If there is only one component, show it and return.
Index: java/awt/CardLayout.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/CardLayout.java,v
retrieving revision 1.9
diff -u -r1.9 CardLayout.java
--- java/awt/CardLayout.java 3 Feb 2004 17:10:50 -0000 1.9
+++ java/awt/CardLayout.java 18 Feb 2004 19:42:50 -0000
@@ -103,6 +103,11 @@
public void addLayoutComponent (String name, Component comp)
{
tab.put (name, comp);
+ // First component added is the default component.
+ if (tab.size() == 1)
+ comp.setVisible(true);
+ else
+ comp.setVisible(false);
}
/** Cause the first component in the container to be displayed.
@@ -243,6 +248,8 @@
if (tab.get (key) == comp)
{
tab.remove (key);
+ Container parent = comp.getParent();
+ next(parent);
break;
}
}
@@ -311,6 +318,13 @@
int num = parent.ncomponents;
// This is more efficient than calling getComponents().
Component[] comps = parent.component;
+
+ if (num == 1)
+ {
+ comps[0].setVisible(true);
+ return;
+ }
+
int choice = -1;
if (what == FIRST)