summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-07-25 19:20:28 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-07-25 19:20:28 +0000
commit549874eb72fc6025ceeff817b05c3f0ce1dd03c2 (patch)
tree98c4ea61a983c752e7db1e7d2ffc07cf253d92a5
parentbf56eff91b7a9e15c8ed0d0f2d3879eba0929550 (diff)
downloadclasspath-549874eb72fc6025ceeff817b05c3f0ce1dd03c2.tar.gz
2006-07-25 Robert Schuster <robertschuster@fsfe.org>
* javax/swing/JTabbedPane.java: (remove(Component)): Rewritten. (setSelectedIndex): Implemented updating of component visibility state.
-rw-r--r--ChangeLog6
-rw-r--r--javax/swing/JTabbedPane.java31
2 files changed, 35 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 43af1bd6a..1c164148e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/JTabbedPane.java:
+ (remove(Component)): Rewritten.
+ (setSelectedIndex): Implemented updating of component visibility state.
+
2006-07-25 Sven de Marothy <sven@physto.se>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
diff --git a/javax/swing/JTabbedPane.java b/javax/swing/JTabbedPane.java
index ee6af857e..a7cc99fe1 100644
--- a/javax/swing/JTabbedPane.java
+++ b/javax/swing/JTabbedPane.java
@@ -990,7 +990,17 @@ public class JTabbedPane extends JComponent implements Serializable,
checkIndex(index, -1, tabs.size());
if (index != getSelectedIndex())
{
+ // Hiding and showing the involved components
+ // is important for the focus traversal mechanism
+ // to report the correct source and destination
+ // components.
+ Component c = getSelectedComponent();
+ if (c != null)
+ c.setVisible(false);
+
model.setSelectedIndex(index);
+
+ getSelectedComponent().setVisible(true);
}
}
@@ -1247,7 +1257,25 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void remove(Component component)
{
- super.remove(component);
+ // Container.remove(Component) is implemented in a
+ // way that it calls Container.remove(int). Since
+ // JTabbedPane's remove(int) is overridden to
+ // remove tabs and this in turn should not happen
+ // with components implementing UIResource
+ // we find out the component's index and
+ // call the superclass' remove(int) method
+ // directly.
+ // For non-UIResource implementing components
+ // the normal implementation is suitable.
+ if (component instanceof UIResource)
+ {
+ Component[] cs = getComponents();
+ for (int i = 0; i< cs.length; i++)
+ if (cs[i] == component)
+ super.remove(i);
+ }
+ else
+ super.remove(component);
}
/**
@@ -1257,7 +1285,6 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void remove(int index)
{
- super.remove(index);
removeTabAt(index);
}