JOptionPane input focus issue



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);

--
And loving it,

qu0ll
______________________________________________
qu0llSixFour@xxxxxxxxx
(Replace the "SixFour" with numbers to email)


.



Relevant Pages

  • Re: Polymorphism in Java SE?
    ... Swing makes heavy use of polymorphism, and does so for good reasons. ... final JOptionPane optionPane = new JOptionPane( ... public static String repeat(String s, ...
    (comp.lang.java.programmer)
  • Re: help...
    ... public static void main{ ... String name = JOptionPane.showMessageDialog(null, "Hello world: ... You just need to code JOptionPane this way. ... Look at the JOptionPane API here: ...
    (comp.lang.java.beans)
  • Re: help...
    ... public static void main{ ... String name = JOptionPane.showMessageDialog(null, "Hello world: ... You just need to code JOptionPane this way. ... Look at the JOptionPane API here: ...
    (comp.lang.java.beans)
  • Re: JOption Pane/ How to check string
    ... >> I am new to Java ... >>..and my teacher wants us to use the JOptionPane to input ... It appears to only return a string. ... > You can provide JOptionPane any arbitrary Object ...
    (comp.lang.java.programmer)
  • Re: getParentDirectory
    ... >Then I have to convert it back to String in order to display it with ... >JOptionPane. ... http://mindprod.com Java custom programming, consulting and coaching. ...
    (comp.lang.java.gui)