I am trying to use JOptionPane to allow a user to enter some String 
data.  Things are going well but I can't initialize the input 
textfield with a value.  This is for part of a Preference panel, so I 
want to initialize it with the old preference string.  The problem is 
that despite using JOptionPane's setInputValue(), the dialog's 
textfield initially comes up empty.  Am I going about this wrong? 
The code  is below.

     private void setAutoSendPassword()
     {
         String message = "Enter password for auto-send:";
         String password = autoSendPassword;
         JOptionPane jop = new JOptionPane(message,
                                           JOptionPane.QUESTION_MESSAGE,
                                           JOptionPane.OK_CANCEL_OPTION);
         jop.setWantsInput(true);
         jop.setInputValue(password);
         JDialog dialog = jop.createDialog(this, "Enter Password");
         dialog.setResizable(false);
         dialog.toFront();
         dialog.setVisible(true);
         Object selectedValue = jop.getValue();
         if (selectedValue != null)
         {
             password = (String)jop.getInputValue();
             autoSendPassword = password;
         }
     }

I am running this on Mac OS X (using JRE 1.3)


Also, as you can see, I am using this to enter a password.  Is there 
a way to get JOptionPane to use a JPasswordField rather than a 
JTextField???

Thanks.
-- 
Bill Tschumy
Otherwise -- Austin, TX
[EMAIL PROTECTED]
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to