• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

action events

 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys,
i want to perform this action. say for example, there is a "search button" and i want to get the search button activated when i press "enter" button on the key board. please replay soon.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JRootPane().setDefaultButton(JButton);
Then of course you need an ActionListener registered on your JButton with an ActionEvent.
If you are just using a JPanel, you can get the root pane as follows
myPanel.getRootPane()
Hope that helps.
BTW - This probably goes in the JFS/Swing/AWT forum.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:
Then of course you need an ActionListener registered on your JButton with an ActionEvent.


To do that:
1. Create an instance of your Button in the GUI code.
2. Create an instance of a Listener that does whatever you want it to. (You may need to write your own class here, and then create an instance of it in your GUI code).
3. Link them together in the GUI using
myButton.addActionListener(myListener);
Moving to the Swing forum.
[ February 18, 2003: Message edited by: Cindy Glass ]
 
knowledge is the difference between drudgery and strategic action -- tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic