X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libjava%2Fclasspath%2Fjavax%2Fswing%2FJTabbedPane.java;h=5c8d0474852258419cdb4d2aea5638603e758d5f;hb=ffde862e033a0825e1e9972a89c0f1f80b261a8e;hp=ee6af857ee33436d0e75908553d1bbb5fc104783;hpb=b415ff10527e977c3758234fd930e2c027bfa17d;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libjava/classpath/javax/swing/JTabbedPane.java b/libjava/classpath/javax/swing/JTabbedPane.java index ee6af857ee3..5c8d0474852 100644 --- a/libjava/classpath/javax/swing/JTabbedPane.java +++ b/libjava/classpath/javax/swing/JTabbedPane.java @@ -990,6 +990,8 @@ public class JTabbedPane extends JComponent implements Serializable, checkIndex(index, -1, tabs.size()); if (index != getSelectedIndex()) { + // Hiding and showing the involved components + // is done by the JTabbedPane's UI. model.setSelectedIndex(index); } } @@ -1247,7 +1249,32 @@ public class JTabbedPane extends JComponent implements Serializable, */ public void remove(Component component) { - super.remove(component); + // Since components implementing UIResource + // are not added as regular tabs by the add() + // methods we have to take special care when + // removing these object. Especially + // Container.remove(Component) cannot be used + // because it will call JTabbedPane.remove(int) + // later which is overridden and can only + // handle tab components. + // This implementation can even cope with a + // situation that someone called insertTab() + // with a component that implements UIResource. + int index = indexOfComponent(component); + + // If the component is not a tab component + // find out its Container-given index + // and call that class' implementation + // directly. + if (index == -1) + { + Component[] cs = getComponents(); + for (int i = 0; i< cs.length; i++) + if (cs[i] == component) + super.remove(i); + } + else + removeTabAt(index); } /** @@ -1257,7 +1284,6 @@ public class JTabbedPane extends JComponent implements Serializable, */ public void remove(int index) { - super.remove(index); removeTabAt(index); }