472,353 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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
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
Jul 17 '05 #1
0 22001

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Java and Swing | last post by:
Hi, I have been posting about writing a C extension for Python...so far, so good. At least for the "simple" functions that I need to wrap. Ok,...
23
by: Nascimento | last post by:
Hello, How to I do to return a string as a result of a function. I wrote the following function: char prt_tralha(int num) { int i; char...
4
by: Woody Splawn | last post by:
How would I pass an array back to a sub routine from a function? That is, I have a function that looks like this Public Function arrayTest() As...
1
by: cornedbeef007-groups | last post by:
I have built a database for dog pedigrees. I want to be able to display the siblings for a dog on it's pedigree. I am able to find the names in my...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char...
10
by: vignesh4u | last post by:
I am trying to implement the Split function in C ie. if i have a string: char* S="This is a test"; and if i try to split based on space ' ' it...
20
by: Andrew Morton | last post by:
Is it possible to have two function declarations which take the same parameters but return different types depending on how the function is used? ...
1
by: jef.d | last post by:
I am attempting to read through a text file & then update an HTML page table w/ the output from the text file (ie; statusing by table). What I...
11
by: Rahul | last post by:
Hi Everyone, I have seen code in different styles like main(argc,argv) int argc; char **argv; { if(argc != 2) exit(1); else exit(0);
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.