In JTabbedPane.getSelectedComponent() we need to check if
getSelectedIndex() returns -1 (== no tab selected) and return null if
that is the case. Otherwise we get an IndexOutOfBoundsException when we
should not.
2006-03-24 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/JTabbedPane.java
(getSelectedComponent): Return null when no component is
selected.
/Roman
Index: javax/swing/JTabbedPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTabbedPane.java,v
retrieving revision 1.33
diff -u -1 -0 -r1.33 JTabbedPane.java
--- javax/swing/JTabbedPane.java 23 Mar 2006 15:37:05 -0000 1.33
+++ javax/swing/JTabbedPane.java 24 Mar 2006 12:55:30 -0000
@@ -952,21 +952,25 @@
}
}
/**
* This method returns the component at the selected index.
*
* @return The component at the selected index.
*/
public Component getSelectedComponent()
{
- return getComponentAt(getSelectedIndex());
+ int selectedIndex = getSelectedIndex();
+ Component selected = null;
+ if (selectedIndex >= 0)
+ selected = getComponentAt(selectedIndex);
+ return selected;
}
/**
* This method sets the component at the selected index.
*
* @param c The component associated with the selected index.
*/
public void setSelectedComponent(Component c)
{
if (c.getParent() == this)