473,890 Members | 1,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.setL ayout(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.CE NTER);
/********** SOUTH PANE BUTTONS *********/
JPanel buttonPanel = new JPanel();

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

okButton.addAct ionListener(
new ActionListener( ){
public void actionPerformed (ActionEvent e)
{
value[0] = LoginText.getTe xt();
value[1] = PasswordText.ge tText();;
///// return the value array to application
}});

cancelButton.ad dActionListener (
new ActionListener( ){
public void actionPerformed (ActionEvent e)
{
System.out.prin tln("cancel boton");
System.exit(0);

}
});
buttonPanel.add (okButton);
buttonPanel.add (cancelButton);

contentPane.add (buttonPanel, BorderLayout.SO UTH);
pack();
return value;

}
--
Be yourself everybody else is already taken

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

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

Similar topics

6
6331
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 *doNumberStuff(const char *in, const char *x) { ... } MY_NUM is defined as, typedef unsigned long MY_NUM; (not sure if that matters, or can i just create a wrapper which handles longs?)
23
3623
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
40903
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", "WA" _ } Return states End Function
1
2414
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 concatenated into one long string. Problem is a large litter can exceed 255 characters of a string. I thing a better solution is to assign the dogs names to an array of strings and return that from the UDF as type variant. My problem now is, how...
18
4078
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
5922
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: {"This","is","a","test"} . I tried to implement it as given below but am getting a segmentation fault. I would really appreciate if some one could give me an answer on this issue:
20
9023
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 function function f(x) as string() ' return an array of strings end function
1
1692
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 for a line that matches a couple of strings, next is loop through the file from that match to 30 lines searching for a "score" from, then store that score; and then look for the next algorithm (8 of them) run & score. What I get is an array w/...
11
2855
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
9978
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9630
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8016
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.