javax.swing.plaf.basic
Class BasicPopupMenuUI.MenuKeyboardHelper

java.lang.Object
  extended byjavax.swing.plaf.basic.BasicPopupMenuUI.MenuKeyboardHelper
All Implemented Interfaces:
ChangeListener, EventListener, KeyListener
Enclosing class:
BasicPopupMenuUI

private static class BasicPopupMenuUI.MenuKeyboardHelper
extends Object
implements ChangeListener, KeyListener

This helper is added to MenuSelectionManager as a ChangeListener to listen to menu selection changes. When a menu is activated, it passes focus to its parent JRootPane, and installs an ActionMap/InputMap pair on that JRootPane. Those maps are necessary in order for menu navigation to work. When menu is being deactivated, it restores focus to the component that has had it before menu activation, and uninstalls the maps. This helper is also installed as a KeyListener on root pane when menu is active. It forwards key events to MenuSelectionManager for mnemonic keys handling.


Field Summary
private  boolean focusTraversalKeysEnabled
           
private  JRootPane invokerRootPane
           
private  Component lastFocused
           
private  MenuElement[] lastPathSelected
           
private  JPopupMenu lastPopup
           
private  ActionMap menuActionMap
           
private  InputMap menuInputMap
           
private  boolean receivedKeyPressed
           
private  FocusListener rootPaneFocusListener
           
 
Constructor Summary
private BasicPopupMenuUI.MenuKeyboardHelper()
           
 
Method Summary
(package private)  void addUIActionMap(JComponent c, ActionMap map)
           
(package private)  void addUIInputMap(JComponent c, InputMap map)
           
(package private)  JPopupMenu getActivePopup(MenuElement[] path)
          Return the last JPopupMenu in path, or null if none found
 void keyPressed(KeyEvent ev)
          Invoked when a key has been pressed.
 void keyReleased(KeyEvent ev)
          Invoked when a key has been released.
 void keyTyped(KeyEvent ev)
          Invoked when a key has been typed.
(package private)  void removeItems()
           
(package private)  void removeUIActionMap(JComponent c, ActionMap map)
           
(package private)  void removeUIInputMap(JComponent c, InputMap map)
           
 void stateChanged(ChangeEvent ev)
          Invoked when the target of the listener has changed its state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastFocused

private Component lastFocused

lastPathSelected

private MenuElement[] lastPathSelected

lastPopup

private JPopupMenu lastPopup

invokerRootPane

private JRootPane invokerRootPane

menuActionMap

private ActionMap menuActionMap

menuInputMap

private InputMap menuInputMap

focusTraversalKeysEnabled

private boolean focusTraversalKeysEnabled

receivedKeyPressed

private boolean receivedKeyPressed

rootPaneFocusListener

private FocusListener rootPaneFocusListener
Constructor Detail

BasicPopupMenuUI.MenuKeyboardHelper

private BasicPopupMenuUI.MenuKeyboardHelper()
Method Detail

removeItems

void removeItems()

getActivePopup

JPopupMenu getActivePopup(MenuElement[] path)
Return the last JPopupMenu in path, or null if none found


addUIInputMap

void addUIInputMap(JComponent c,
                   InputMap map)

addUIActionMap

void addUIActionMap(JComponent c,
                    ActionMap map)

removeUIInputMap

void removeUIInputMap(JComponent c,
                      InputMap map)

removeUIActionMap

void removeUIActionMap(JComponent c,
                       ActionMap map)

stateChanged

public void stateChanged(ChangeEvent ev)
Description copied from interface: ChangeListener
Invoked when the target of the listener has changed its state.

Specified by:
stateChanged in interface ChangeListener
Parameters:
ev - a ChangeEvent object

keyPressed

public void keyPressed(KeyEvent ev)
Description copied from interface: KeyListener
Invoked when a key has been pressed. See the class description for KeyEvent for a definition of a key pressed event.

Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ev)
Description copied from interface: KeyListener
Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.

Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent ev)
Description copied from interface: KeyListener
Invoked when a key has been typed. See the class description for KeyEvent for a definition of a key typed event.

Specified by:
keyTyped in interface KeyListener