Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

Creating a "default" button when hitting the Return/Enter key?

Thread view: 
Chris Shepherd - 19 Dec 2003 06:34 GMT
I'm just wondering how I can create a "default" button click when hitting the
Return/Enter key. In VB, this is simply a matter of assigning a specific propery
to the default button to be pressed, but I am at a loss for how to do it in Java
without using an ActionListener. Is there a similar way of doing it?

Signature

Chris Shepherd

Alex Molochnikov - 19 Dec 2003 06:58 GMT
JRootPane.setDefaultButton(JButton defaultButton)

HTH

Alex Molochnikov
Gestalt Corporation
www.gestalt.com

> I'm just wondering how I can create a "default" button click when hitting the
> Return/Enter key. In VB, this is simply a matter of assigning a specific propery
[quoted text clipped - 3 lines]
> --
> Chris Shepherd
Chris Shepherd - 19 Dec 2003 16:25 GMT
> JRootPane.setDefaultButton(JButton defaultButton)

Thanks a bundle! I knew it was simpler than I'd initially figured it would be.

Signature

Chris Shepherd

Andrew Thompson - 19 Dec 2003 08:38 GMT
> I'm just wondering how I can create a "default" button click when hitting the
> Return/Enter key. In VB, this is simply a matter of assigning a specific propery
> to the default button to be pressed, but I am at a loss for how to do it in Java
> without using an ActionListener. Is there a similar way of doing it?

I really have no idea what you mean with the
VB example, but am curious as to why you
do _not_ want to use an action listener?

An ActionListener would be the Java way
to act on button clicks.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Chris Shepherd - 19 Dec 2003 16:20 GMT
> I really have no idea what you mean with the
> VB example, but am curious as to why you
> do _not_ want to use an action listener?
>
> An ActionListener would be the Java way
> to act on button clicks.

Except, say I have a window with 30 or so JTextFields on it. Not all of it needs
data entered, etc.. I need it as a data entry application, and when I hit return
I want it to submit the changes and change to a new window. To do it with an
actionlistener would require that for each of the 30 JTextFields I set the
ActionListener object, and that's a lot more difficult and convoluted than
simply having a button press associated with enter, like the other poster in
this thread gave. Basically I'm aiming for efficiency and saving work. :)

Signature

Chris Shepherd



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.