I am trying to return an array of strings (basicaly the contents of the
textfield) to the main class... when i put this piece of code it tells me
that i need to declare the array of strings final but if i do then they
don't change in the action listener. any suggestions on how to make this
work?
public String[] drawLoginPopUp( )
{
//Description: This method draws the pop up window for entering the
userName and password with 'OK' and 'Cancel' buttons.
String value[] = new String [2];
Container contentPane = getContentPane();
JPanel LoginPanel = new JPanel();
LoginPanel.setLayout(new GridLayout(2,2));
JLabel LoginLabel = new JLabel(" Login: ");
JTextField LoginText = new JTextField("", 10);
JLabel PasswordLabel = new JLabel (" Password: ");
JPasswordField PasswordText = new JPasswordField("", 10);
LoginPanel.add(LoginLabel);
LoginPanel.add(LoginText);
LoginPanel.add(PasswordLabel);
LoginPanel.add(PasswordText);
contentPane.add(LoginPanel, BorderLayout.CENTER);
/********** SOUTH PANE BUTTONS *********/
JPanel buttonPanel = new JPanel();
JButton okButton = new JButton("OK");
JButton cancelButton = new JButton("Cancel");
okButton.addActionListener(
new ActionListener(){
public void actionPerformed (ActionEvent e)
{
value[0] = LoginText.getText();
value[1] = PasswordText.getText();;
///// return the value array to application
}});
cancelButton.addActionListener(
new ActionListener(){
public void actionPerformed (ActionEvent e)
{
System.out.println("cancel boton");
System.exit(0);
}
});
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
contentPane.add(buttonPanel, BorderLayout.SOUTH);
pack();
return value;
}
--
Be yourself everybody else is already taken
--
Be yourself everybody else is already taken