This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

to identify keypressed event in java

 
Gayani Kanchana
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my program i want some task to run when user pressed any key.i am running my program in console mode.how to identify when user press any key.please help.

thanks
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't be done in the J2SE. The stream from the console is buffered, so we only get data after a line feed (i.e. after the user presses "enter").
I've done it using JNI, but really, if you want a fully-featured GUI, use AWT or Swing.
 
sudhakar ananth
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you tell how to do in swing
it really needed to me...
bye...
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Tutorial: How to write a Key Listener
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic