This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make buttons react to keyboard (Hotkey functionality)

 
Maysam Sorkhabi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm developing a chat client and I need to know how I can have my "send" button work when the "Enter" key is pressed on the keybaord. It would be annoying to have to move the mouse everytime and click on "send" for some text to be sent; it is much easier to press Enter key on keyboard instead. I know a little about event handling. If there is a tutorial somewhere or you can provide me with a quick piece of code I would appreciate it vert much.
-Thank you
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try something like this:

inside the JFrame/JDialog code where this refers to the JFrame / JDialog/ JWindow.

Tanveer
[ July 27, 2004: Message edited by: Tanveer Rameez ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!