Listening to JMenuItem keyboard focus
I need to set an appropriate status bar message depending upon which menuitem currently has keyboard focus. Thus, using only the up and down keys to navigate through a JMenu's menuitems, which listener should I use in order to know that currently which JMenuItem has keyboard focus?
I tried using FocusListener but to no avail.
JMenuItem myMenuItem = new JMenuItem("My Menu Item"); myMenuItem.addFocusListener(new FocusListener()
public void focusGained(FocusEvent focusEvent)
System.out.println("'myMenuItem' has current focus");
If indeed FocusListener IS the listener that I'm looking for, then it could be that my code's somehow problematic. Otherwise it could be a different listener that I'm looking for. Thanks.