• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

swing login application

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
stanleyhuen
Asked:
stanleyhuen
  • 2
1 Solution
 
objectsCommented:
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
 
Venci75Commented:
... 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
 
objectsCommented:
> ... 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
 
randydCommented:
it's different because it is a concrete example :)

randy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now