This avoids an ArrayIndexOutOfBoundsException when the array length is
0.
2006-06-06 Roman Kennke <[EMAIL PROTECTED]>
PR 27523
* javax/swing/MenuSelectionManager.java
(processKeyEvent): Added check to avoid
ArrayIndexOutOfBoundsException.
/Roman
Index: javax/swing/MenuSelectionManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/MenuSelectionManager.java,v
retrieving revision 1.17
diff -u -1 -0 -r1.17 MenuSelectionManager.java
--- javax/swing/MenuSelectionManager.java 2 May 2006 13:04:22 -0000 1.17
+++ javax/swing/MenuSelectionManager.java 6 Jun 2006 13:53:33 -0000
@@ -251,20 +251,23 @@
* instances should always forward their key events to this method and
* get their [EMAIL PROTECTED] MenuElement#processKeyEvent(KeyEvent, MenuElement[],
* MenuSelectionManager)} eventually called back.
*
* @param e the key event
*/
public void processKeyEvent(KeyEvent e)
{
MenuElement[] selection = (MenuElement[])
selectedPath.toArray(new MenuElement[selectedPath.size()]);
+ if (selection.length == 0)
+ return;
+
MenuElement[] path;
for (int index = selection.length - 1; index >= 0; index--)
{
MenuElement el = selection[index];
// This method's main purpose is to forward key events to the
// relevant menu items, so that they can act in response to their
// mnemonics beeing typed. So we also need to forward the key event
// to all the subelements of the currently selected menu elements
// in the path.
MenuElement[] subEls = el.getSubElements();