ActionEvent - accelerator key OR menu item cilcked?

Posted on 2004-11-17
Last Modified: 2008-03-04
public void actionPerformed(ActionEvent e)

how do i know if a menu action was fired by the user clicking the menu item, or by using an accelerator key??  note that the accelerator key is DELETE, so i cannot check for modifier keys like ctrl, alt, shift!!

Question by:cathalmchale
    LVL 92

    Accepted Solution

    afaik you can't
    LVL 92

    Expert Comment

    why should it make a difference?
    LVL 35

    Assisted Solution

    You can *probably* capture the DELETE key if you have a KeyEvent. Then you could do something like:

    int keycode = keyEvent.getKeycode();
    if (keycode == KeyEvent.VK_DELETE)
        // blah blah

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now