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 / October 2006

Tip: Looking for answers? Try searching our database.

JOptionPane input focus issue

Thread view: 
qu0ll - 31 Oct 2006 13:20 GMT
I have a JOptionPane with a string and a text field as the "message" part.
It works but I would like input focus to default to the text field when the
dialog is displayed to save the user having to click into it each time.  How
can I achieve this?  Do I need to actually create a JOptionPane explicitly
or subclass it?

The code is as follows:

JTextField nameTextField = new JTextField();
Object[] message = {"Enter a name:", nameTextField};
int option = JOptionPane.showOptionDialog(null, message, "Enter Name",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);

Signature

And loving it,

qu0ll
______________________________________________
qu0llSixFour@gmail.com
(Replace the "SixFour" with numbers to email)

Ian Wilson - 31 Oct 2006 17:23 GMT
> I have a JOptionPane with a string and a text field as the "message" part.
> It works but I would like input focus to default to the text field when the
[quoted text clipped - 8 lines]
> int option = JOptionPane.showOptionDialog(null, message, "Enter Name",
> JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);

I now use (or extend) JDialog whenever JOptionPane seems to be running
out of flexibility. The case you describe is what first prompted me to
do this.


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



©2008 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.