Results 1 to 5 of 5
  1. #1
    KingOfClubs is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default Is there a way to wait for input from a button?

    Hi guys, I hope this one will be easy for you :)

    I have a client connected to a server. How can I loop the client to wait until a user presses a Jbutton?
    For example:
    server waits for input=>client clicks a button => sends data to server =>server replies =>client receives data and does something=>client continues to wait for a button click=>server waits for input

    I know if I use
    Java Code:
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in) 
    message = stdin.readLine();
    will wait for keyboard input. What do i do for a button input?
    Thank You

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default

    Thanks Kevin

    To the original poster, please post links to all cross-posts as this will encourage more folks to help you here and in the other forums. Thanks!

  4. #4
    KingOfClubs is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    I'm sorry for spamming your wonderful forum, and wasting your precious time.
    Hang me. Thread solved, delete it.

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

    Default

    Quote Originally Posted by KingOfClubs View Post
    I'm sorry for spamming your wonderful forum, and wasting your precious time.
    Hang me. Thread solved, delete it.
    If you read the link that Kevin provided in your cross-post, you'd understand why cross-posting without notification is an issue when you ask for free advice in a forum. Please check the links before you stick your foot in your mouth again.

Similar Threads

  1. how do i use jframe button to send input selection
    By earnest in forum New To Java
    Replies: 5
    Last Post: 04-04-2011, 08:46 PM
  2. wait() and notify()
    By jomypgeorge in forum New To Java
    Replies: 4
    Last Post: 02-15-2011, 08:58 AM
  3. Wait() Question
    By rsvr in forum Threads and Synchronization
    Replies: 3
    Last Post: 04-27-2010, 03:39 PM
  4. Need help with wait() and notify()
    By Mkaveli in forum Threads and Synchronization
    Replies: 2
    Last Post: 03-30-2010, 11:58 AM
  5. Why doesnt my code wait for input?
    By Addez in forum New To Java
    Replies: 7
    Last Post: 08-19-2009, 10:25 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
  •