aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JTextField and JButton: share the same event handler Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTextField and JButton: share the same event handler" Watch "JTextField and JButton: share the same event handler" New topic
Author

JTextField and JButton: share the same event handler

Mousa A. Rafi
Greenhorn

Joined: Jan 30, 2005
Posts: 28
I've a JFrame that has a JTextField and a JButton object. After typing something in the Textfield I want the JButton to be clicked when I hit Enter.
How can I do it? Does it have something to do with Actions?

Code example will be helpful. Thanks in advance.
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230



This is one of several ways. You could also create an Action and give both components and instance of said Action. Most of the code would look the same though.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
here's another way

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextField and JButton: share the same event handler
 
Similar Threads
Simple Calculator help
How To make Button Display in JTextarea
Beginning GUI programming exercise. Please help to figure out why it does not compile.
MouseListener - mouseEntered question.
setFocus in JButton is there any?