take value other form
I have a problem like this:
I have a form LogIn with 2 textfileds Username and Password
when i enter a correct username and password , application will hide a LogIn form and show form 2
What i want to ask is how to take a Username value that i just entered in form LogIn and and set to the TextField in form 2 like " Welcome (username value from Log In form)" ?
public String user = UserName.getText();
LogIn log =new LogIn();
and that not work ! the textfield is blank...
Help me !!
by "Form" do you mean JFrame? Myself, I'd have a public method in the first class, the one responsible for handling your login GUI, something like so:
Then in the second class, when I wanted this data, I'd call this method on an instance of the first class (the instance that was displayed!).
public String getUserName()
// assuming that this class has a private JTextField variable
// named userNameTextField
oh thanks, i 'll try that, thanks for reply!
I already tried that, but did'nt work
private JTextField userName;
public String getUsername()
LogIn log = new LogIn();
the text in the JtextField is blank T_T
Well, if you've just instantiated the Login class, the userName JTextField is blank, isn't it? And that's where you're getting the text that you're setting to....
Hey wait. setText isn't a static method, you can't invoke it on the class.
Hop across to the Sun site and find the Swing tutorial. You need it badly.