This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

implementing "Enter" short cut key  RSS feed

 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to implement "Enter" short cut key on the OK buttons in my swing components (JPanel and JInternalFrames)
Thanks
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm shure, there are many ways of doing this. One way is, that your JFrame listens for keys. Everytime "Enter" key is pressed, you can send a message to other listening components (JPanel, JInternalFrame). They can do something, when they catch this event. You may ask now, how do you add the components as a listener to your JFrame. One possibility would be the work with Observer and Observable. An other way would be using PropertyChangedEvent.
The only fact is (as I know), the JFrame is the only component, which knows all key events, no matter which component the focus has.
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to remove the Enter Binding from Key map. It does not work right to me.
Could you post some examples with Observer/Observable?
I dont understand why some simple features are made so complicated to code.Like making a button as a "Default Button" in a Component.
Thanks
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a small example:
File 1 TestJFrame.java

File 2 MyBean.java

Hope this helps you
Rene
 
Jawad Kakar
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hostName is a JTextField, which is listening to ENTER key.

hope this will help
Jawad
[ November 07, 2002: Message edited by: Jawad Kakar ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!