Solved

swing login application

Posted on 2002-06-24
4
202 Views
Last Modified: 2012-05-04
I am writing a swing login application.
I have a screen have "username" and "password" fields,
after a user logined then he will go to a screen which he can change his password, but how can I bring the username from first screen to second screen?
0
Comment
Question by:stanleyhuen
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 7106471
You just need to store the userid somewhere that is accessible from the second screen.
Or store the userid and pass it to the second screen when you need to display it.
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 200 total points
ID: 7106657
... or store it in a static variable - then it will be global for the whole application:
public class MyClass {
public static String user = "user1";
.....
}

set it by using:
MyClass.user = "new_user";

and get it:
String user = MyClass.user;

0
 
LVL 92

Expert Comment

by:objects
ID: 7106669
> ... or store it in a static variable

How is that different than:

"You just need to store the userid somewhere that is accessible from the second screen"

:-)
0
 
LVL 3

Expert Comment

by:randyd
ID: 7111471
it's different because it is a concrete example :)

randy
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question