592 * Open the Menu 593 */ 594 public void menuKeyTyped(MenuKeyEvent e) { 595 if (!crossMenuMnemonic && BasicPopupMenuUI.getLastPopup() != null) { 596 // when crossMenuMnemonic is not set, we don't open a toplevel 597 // menu if another toplevel menu is already open 598 return; 599 } 600 601 if (BasicPopupMenuUI.getPopups().size() != 0) { 602 //Fix 6939261: to return in case not on the main menu 603 //and has a pop-up. 604 //after return code will be handled in BasicPopupMenuUI.java 605 return; 606 } 607 608 char key = Character.toLowerCase((char)menuItem.getMnemonic()); 609 MenuElement path[] = e.getPath(); 610 if (key == Character.toLowerCase(e.getKeyChar())) { 611 JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu(); 612 ArrayList newList = new ArrayList(Arrays.asList(path)); 613 newList.add(popupMenu); 614 MenuElement subs[] = popupMenu.getSubElements(); 615 MenuElement sub = 616 BasicPopupMenuUI.findEnabledChild(subs, -1, true); 617 if(sub != null) { 618 newList.add(sub); 619 } 620 MenuSelectionManager manager = e.getMenuSelectionManager(); 621 MenuElement newPath[] = new MenuElement[0];; 622 newPath = (MenuElement[]) newList.toArray(newPath); 623 manager.setSelectedPath(newPath); 624 e.consume(); 625 } 626 } 627 628 public void menuKeyPressed(MenuKeyEvent e) {} 629 public void menuKeyReleased(MenuKeyEvent e) {} 630 } 631 } | 592 * Open the Menu 593 */ 594 public void menuKeyTyped(MenuKeyEvent e) { 595 if (!crossMenuMnemonic && BasicPopupMenuUI.getLastPopup() != null) { 596 // when crossMenuMnemonic is not set, we don't open a toplevel 597 // menu if another toplevel menu is already open 598 return; 599 } 600 601 if (BasicPopupMenuUI.getPopups().size() != 0) { 602 //Fix 6939261: to return in case not on the main menu 603 //and has a pop-up. 604 //after return code will be handled in BasicPopupMenuUI.java 605 return; 606 } 607 608 char key = Character.toLowerCase((char)menuItem.getMnemonic()); 609 MenuElement path[] = e.getPath(); 610 if (key == Character.toLowerCase(e.getKeyChar())) { 611 JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu(); 612 ArrayList<MenuElement> newList = new ArrayList<>(Arrays.asList(path)); 613 newList.add(popupMenu); 614 MenuElement subs[] = popupMenu.getSubElements(); 615 MenuElement sub = 616 BasicPopupMenuUI.findEnabledChild(subs, -1, true); 617 if(sub != null) { 618 newList.add(sub); 619 } 620 MenuSelectionManager manager = e.getMenuSelectionManager(); 621 MenuElement newPath[] = new MenuElement[0];; 622 newPath = newList.toArray(newPath); 623 manager.setSelectedPath(newPath); 624 e.consume(); 625 } 626 } 627 628 public void menuKeyPressed(MenuKeyEvent e) {} 629 public void menuKeyReleased(MenuKeyEvent e) {} 630 } 631 } |