how to set accelerator on JMenuItem?

hello,all
I want to know how to set accelerator on JMenuItem.I used to add accelerator on MenuItem.The way is like this:

MenuShortcut shortcut=new MenuShortcut (KeyEvent.VK_N);
menuItemNew.setShortcut(shortcut);

then in MenuItem,it's OK.But i can't do this in JMenuItem.what should I do?

by the way,how can I add a short line under a menu.For example ,in many applications if there is a menu File,there must be a short line under the character "F". How can I realize it in my application?

Comments

  • : hello,all
    : I want to know how to set accelerator on JMenuItem.I used to add accelerator on MenuItem.The way is like this:
    :
    : MenuShortcut shortcut=new MenuShortcut (KeyEvent.VK_N);
    : menuItemNew.setShortcut(shortcut);
    :
    : then in MenuItem,it's OK.But i can't do this in JMenuItem.what should I do?
    :
    : by the way,how can I add a short line under a menu.For example ,in many applications if there is a menu File,there must be a short line under the character "F". How can I realize it in my application?
    :
    The setShortcut() is called setAccelerator() or setMnemonic(). The line appears automatically. See javadoc for more info.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion