Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make buttons react to keyboard (Hotkey functionality)  RSS feed

 
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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!