• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

implementing "Enter" short cut key

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a small example:
File 1 TestJFrame.java

File 2 MyBean.java

Hope this helps you
Rene
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
You got style baby! More than this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic