469,362 Members | 2,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

return array of strings

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


contentPane.add(LoginPanel, BorderLayout.CENTER);
/********** SOUTH PANE BUTTONS *********/
JPanel buttonPanel = new JPanel();

JButton okButton = new JButton("OK");
JButton cancelButton = new JButton("Cancel");

new ActionListener(){
public void actionPerformed (ActionEvent e)
value[0] = LoginText.getText();
value[1] = PasswordText.getText();;
///// return the value array to application

new ActionListener(){
public void actionPerformed (ActionEvent e)
System.out.println("cancel boton");


contentPane.add(buttonPanel, BorderLayout.SOUTH);
return value;

Be yourself everybody else is already taken

Be yourself everybody else is already taken
Jul 17 '05 #1
0 21850

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Java and Swing | last post: by
23 posts views Thread by Nascimento | last post: by
4 posts views Thread by Woody Splawn | last post: by
18 posts views Thread by Pedro Pinto | last post: by
10 posts views Thread by vignesh4u | last post: by
20 posts views Thread by Andrew Morton | last post: by
11 posts views Thread by Rahul | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.