Retrieving user input from showOptionDialog

I need help retrieving the input that the user has entered. I have an OptionDialog box with 4 Textfields.

Object[] message = new Object[8];

message[0] = new JLabel("Website");

message[1] = JTextField web = new JTextField ("WebSite Address");

message[2] = new JLabel("Username");

message[3] = new JTextField("Username");

message[4] = new JLabel("Password");

message[5] = new JPasswordField();

message[6] = new JLabel("Notes");

message[7] = new JTextField("Notes about site");

String[] options = {"OK", "Cancel"};

int answer = JOptionPane.showOptionDialog(container, message, "New Entry",JOptionPane.DEFAULT_OPTION, OptionPane.INFORMATION_MESSAGE,

null, options, options[0]);

Now after the user fills out the information and clicks "OK" how do I get the input?

[851 byte] By [mwrfsu] at [2007-9-26 1:37:06]
# 1

Give OPTION_TYPE as YES_NO_OPTION, or YES_NO_CANCEL_OPTION

Then check the value in the answer

if (answer == Ok_OPTON) {

Object [] messages = (OBject) JOptionPane.getMessage();

String name = ((JTextField)messges[0]).getText();

....

....

Like that retrive other values

}

else (answer == CANCEL_OPTION) {

user pressed cancel

}

else (answer == CLOSED_OPTION) {

user closed the window

}

Got it?

redwin at 2007-6-29 2:23:26 > top of Java-index,Archived Forums,Swing...
# 2
Thanks for the reply. Your suggestion worked fine.
mwrfsu at 2007-6-29 2:23:26 > top of Java-index,Archived Forums,Swing...