-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 12/28/2000
Method javax.swing.JTabbedPane.setMnemonicAt(int index, int mnemonic) throws incorrect
exception when index is out of bounds.
The javadoc says:
-----------------------
public void setMnemonicAt(int index,
int mnemonic)
...
Parameters:
index - the tab index to which the mnemonic will be set
mnemonic - the key code which represents the mnemonic
Throws:
IllegalArgumentException - if index is out of bounds
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
----------------------------------------
In fact, the method throws ArrayIndexOutOfBoundsException
instead IllegalArgumentException.
It needs to be fixed.
Here is an example:
---------------------------------------------
import javax.swing.JTabbedPane;
public class test {
public static void main(String[] args) {
JTabbedPane c = new JTabbedPane();
for (int i = 0; i < 3; i++) {
c.addTab("", null, new java.awt.Canvas());
}
// Should throw IAE
try {
c.setMnemonicAt(3, java.awt.event.KeyEvent.VK_A);
} catch (IllegalArgumentException iae) {
System.out.println("PASSED");
}
}
}
---------------------------------------------
Output:
------------------------
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 >= 3
at java.util.Vector.elementAt(Vector.java:418)
at javax.swing.JTabbedPane.setMnemonicAt(JTabbedPane.java:1380)
at test.main(test.java:12)
------------------------
======================================================================