Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Multiple Keyboard Shortcuts on same jMenuItem

Options
  • 12-10-2006 3:15pm
    #1
    Registered Users Posts: 618 ✭✭✭


    Hi Guys,

    Im looking to have two keyboard shortcuts for the same operation.

    for example the operation being "Cut".

    I know that there is the CTRL+X, which is windows specific.
    But I need to create also "Shift+Del" shortcut for the "Cut" operation, that will be application specific.

    But in the JMenuItem of the "Cut" operation, it needs to be
    "Cut Ctrl+X"
    "Copy Ctrl+C"

    I tried
    " menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    "

    But the second accelerator overwrites the first one.
    So in summary, two shortcuts for "Cut"
    CTRL+X,
    "Shift+Del"

    and having "CTRL+X" displayed in the Menu Item.

    thanks guys.....


Comments

  • Registered Users Posts: 1,996 ✭✭✭lynchie


    A MenuItem can only have one keyboard shortcut.


  • Registered Users Posts: 618 ✭✭✭smithslist


    probably i have explained it the wroung way......

    yes a menuitem can only have one shortcut, but using "key binding" you can introduce extra keyboard shortcuts for the same menuitem operation.


Advertisement