473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 22087

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, my c function looks like... MY_NUM...
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 tralha;
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 Array Dim states() As String = { _ "AZ", "CA",...
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 database, and at present return them from a UDF...
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 *string){ alterString(string); return string;
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 should return an array of strings like: ...
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? function f(x) as string ' return a string end...
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 want the code to do is read through the file, look...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.