Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Wait for ActionEvent

  1. #1
    Razion is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default Wait for ActionEvent


    Trying to write a program that involves waiting for a command from the user to do something. More specifically, I want a command from a JTextField to be executed whenever the "Enter" key is pressed. I'm trying to set a String equal to that value, but not sure how to pause and wait. CountDownLatch? Semaphore? Probably not even on the right track with those.

    Any help would be great. Thanks!

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Wait for ActionEvent

    You can include a button with an ActionListener. Once user enters command into textfield they must click the button and the action will be fired.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Wait for ActionEvent

    You can add an ActionListener to a JTextField. Go through the tutorial linked from the API, where you will find code snippets.

    In an event driven scenario, you do not need to 'pause and wait.'

    Razion likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Need help with ActionEvent/ItemEvent
    By patriotsfan in forum AWT / Swing
    Replies: 2
    Last Post: 06-05-2011, 02:17 PM
  2. What does (this) and ActionEvent e mean?
    By africanhacker in forum New To Java
    Replies: 3
    Last Post: 02-06-2011, 05:08 PM
  3. StringBuilder/ActionEvent help!
    By Red727 in forum New To Java
    Replies: 8
    Last Post: 12-07-2010, 03:01 AM
  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