473,805 Members | 2,017 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 22110

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

Similar topics

6
6325
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
3621
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
40887
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
2411
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
4070
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
5915
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
9009
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
1684
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
2851
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
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
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
10356
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
10361
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
10103
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
9179
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...
0
6874
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
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.