From 4f9533c7722fa07511a94d005227961f4a4dec23 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 May 2006 17:29:21 +0000 Subject: Imported GNU Classpath 0.90 Imported GNU Classpath 0.90 * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale. * sources.am: Regenerated. * gcj/javaprims.h: Regenerated. * Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * testsuite/Makefile.in: Regenerated. * gnu/java/lang/VMInstrumentationImpl.java: New override. * gnu/java/net/local/LocalSocketImpl.java: Likewise. * gnu/classpath/jdwp/VMMethod.java: Likewise. * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest interface. * java/lang/Thread.java: Add UncaughtExceptionHandler. * java/lang/reflect/Method.java: Implements GenericDeclaration and isSynthetic(), * java/lang/reflect/Field.java: Likewise. * java/lang/reflect/Constructor.java * java/lang/Class.java: Implements Type, GenericDeclaration, getSimpleName() and getEnclosing*() methods. * java/lang/Class.h: Add new public methods. * java/lang/Math.java: Add signum(), ulp() and log10(). * java/lang/natMath.cc (log10): New function. * java/security/VMSecureRandom.java: New override. * java/util/logging/Logger.java: Updated to latest classpath version. * java/util/logging/LogManager.java: New override. From-SVN: r113887 --- libjava/classpath/javax/swing/JTabbedPane.java | 79 ++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 6 deletions(-) (limited to 'libjava/classpath/javax/swing/JTabbedPane.java') diff --git a/libjava/classpath/javax/swing/JTabbedPane.java b/libjava/classpath/javax/swing/JTabbedPane.java index 3c91a5e..34ab8ee 100644 --- a/libjava/classpath/javax/swing/JTabbedPane.java +++ b/libjava/classpath/javax/swing/JTabbedPane.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing; +import gnu.classpath.NotImplementedException; + import java.awt.Color; import java.awt.Component; import java.awt.Point; @@ -102,6 +104,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @param e the change event describing the change */ public void stateChanged(ChangeEvent e) + throws NotImplementedException { // Implement this properly. } @@ -113,6 +116,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @return the accessible role of the JTabbedPane */ public AccessibleRole getAccessibleRole() + throws NotImplementedException { return null; } @@ -125,6 +129,7 @@ public class JTabbedPane extends JComponent implements Serializable, * JTabbedPane */ public int getAccessibleChildrenCount() + throws NotImplementedException { return 0; } @@ -153,6 +158,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @return the current selection state of the JTabbedPane */ public AccessibleSelection getAccessibleSelection() + throws NotImplementedException { return null; } @@ -169,6 +175,7 @@ public class JTabbedPane extends JComponent implements Serializable, * this location */ public Accessible getAccessibleAt(Point p) + throws NotImplementedException { return null; } @@ -183,6 +190,7 @@ public class JTabbedPane extends JComponent implements Serializable, * JTabbedPane */ public int getAccessibleSelectionCount() + throws NotImplementedException { return 0; } @@ -195,6 +203,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @return DOCUMENT ME! */ public Accessible getAccessibleSelection(int i) + throws NotImplementedException { return null; } @@ -207,6 +216,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @return DOCUMENT ME! */ public boolean isAccessibleChildSelected(int i) + throws NotImplementedException { return false; } @@ -217,6 +227,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @param i DOCUMENT ME! */ public void addAccessibleSelection(int i) + throws NotImplementedException { // TODO: Implement this properly. } @@ -227,6 +238,7 @@ public class JTabbedPane extends JComponent implements Serializable, * @param i DOCUMENT ME! */ public void removeAccessibleSelection(int i) + throws NotImplementedException { // TODO: Implement this properly. } @@ -235,6 +247,7 @@ public class JTabbedPane extends JComponent implements Serializable, * DOCUMENT ME! */ public void clearAccessibleSelection() + throws NotImplementedException { // TODO: Implement this properly. } @@ -243,6 +256,7 @@ public class JTabbedPane extends JComponent implements Serializable, * DOCUMENT ME! */ public void selectAllAccessibleSelection() + throws NotImplementedException { // TODO: Implement this properly. } @@ -379,7 +393,12 @@ public class JTabbedPane extends JComponent implements Serializable, */ public Color getBackground() { - return bg; + Color background; + if (bg == null) + background = JTabbedPane.this.getBackground(); + else + background = bg; + return background; } /** @@ -399,7 +418,12 @@ public class JTabbedPane extends JComponent implements Serializable, */ public Color getForeground() { - return fg; + Color foreground; + if (fg == null) + foreground = JTabbedPane.this.getForeground(); + else + foreground = fg; + return foreground; } /** @@ -585,12 +609,14 @@ public class JTabbedPane extends JComponent implements Serializable, } public AccessibleStateSet getAccessibleStateSet() + throws NotImplementedException { // FIXME: Implement this properly. return null; } public int getAccessibleIndexInParent() + throws NotImplementedException { // FIXME: Implement this properly. return 0; @@ -739,7 +765,6 @@ public class JTabbedPane extends JComponent implements Serializable, public void updateUI() { setUI((TabbedPaneUI) UIManager.getUI(this)); - invalidate(); } /** @@ -950,7 +975,11 @@ public class JTabbedPane extends JComponent implements Serializable, */ public Component getSelectedComponent() { - return getComponentAt(getSelectedIndex()); + int selectedIndex = getSelectedIndex(); + Component selected = null; + if (selectedIndex >= 0) + selected = getComponentAt(selectedIndex); + return selected; } /** @@ -1144,8 +1173,45 @@ public class JTabbedPane extends JComponent implements Serializable, public void removeTabAt(int index) { checkIndex(index, 0, tabs.size()); + + // We need to adjust the selection if we remove a tab that comes + // before the selected tab or if the selected tab is removed. + // This decrements the selected index by 1 if any of this is the case. + // Note that this covers all cases: + // - When the selected tab comes after the removed tab, this simply + // adjusts the selection so that after the removal the selected tab + // is still the same. + // - When we remove the currently selected tab, then the tab before the + // selected tab gets selected. + // - When the last tab is removed, then we have an index==0, which gets + // decremented to -1, which means no selection, which is 100% perfect. + int selectedIndex = getSelectedIndex(); + if (selectedIndex >= index) + setSelectedIndex(selectedIndex - 1); + + Component comp = getComponentAt(index); + + // Remove the tab object. tabs.remove(index); - getComponentAt(index).show(); + + // Remove the component. I think we cannot assume that the tab order + // is equal to the component order, so we iterate over the children + // here to find the and remove the correct component. + if (comp != null) + { + Component[] children = getComponents(); + for (int i = children.length - 1; i >= 0; --i) + { + if (children[i] == comp) + { + super.remove(i); + comp.setVisible(true); + break; + } + } + } + revalidate(); + repaint(); } /** @@ -1175,7 +1241,8 @@ public class JTabbedPane extends JComponent implements Serializable, */ public void removeAll() { - for (int i = tabs.size() - 1; i >= 0; i--) + setSelectedIndex(-1); + for (int i = getTabCount() - 1; i >= 0; i--) removeTabAt(i); } -- cgit v1.1