Results 1 to 3 of 3
  1. #1
    poet is offline Member
    Join Date
    Sep 2009
    Posts
    6
    Rep Power
    0

    Default Check if ctrl is pressed in an ActionEvent

    Greetings,
    This is my first time here, so I'll introduce myself first.
    My name is Itai and I'm from Israel, I took a 10 month course in java that ended about a year ago.
    I am now working as a software developer for a company called EASA software.

    My question is regarding a personal project.

    I have an ActionListener listening to a JideButton and I would like to see if CTRL was held down while the button was clicked.
    Is there a way to do this?

    The other option I thought of is having a static boolean be toggled when the key is pressed or released, and then check if the boolean is true or false. This will probably work, but it would mean a lot of processing that doesn't actually do much.

    Thanks for any direction you may give.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I have an ActionListener listening to a JideButton and I would like to see if CTRL was held down while the button was clicked.
    What is a JideButton? Is that anything like a JButton? If so, you would do well to check the API for the ActionEvent object that is passed to every ActionListener's actionPerformed method. It will have the information that you need.

    http://java.sun.com/j2se/1.5.0/docs/...getModifiers()

    Oh, and welcome to the forum.

  3. #3
    poet is offline Member
    Join Date
    Sep 2009
    Posts
    6
    Rep Power
    0

    Default

    Thanks!

    JideButton is an extention of a JButton by Jidessoft. It is an open source project and they have some very nice swing components available for everyone.

Similar Threads

  1. Problems with ActionEvent for JButton
    By TrueBear in forum AWT / Swing
    Replies: 1
    Last Post: 08-24-2009, 04:26 PM
  2. Replies: 0
    Last Post: 05-23-2009, 04:26 PM
  3. get key pressed
    By prashant in forum Networking
    Replies: 1
    Last Post: 03-26-2009, 09:10 PM
  4. [SOLVED] Actionevent problem
    By Cymro in forum New To Java
    Replies: 3
    Last Post: 04-04-2008, 07:11 AM
  5. ActionEvent example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-11-2008, 11:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •