I'm trying to get that name string from LoginForm to MainForm so I may now the user who logged in with their name. My problem is that, I cant pass the retrieved name from database in LoginForm class to MainForm.
Why is that if I perform this code;
public class LoginForm extends JFrame{
...
.
public LoginForm(){
...
.
MainForm thisoh = new MainForm();
thisoh.getthisnow(rs.getString("Given_Name"));
...
.
}
}
and then, in the other class;
public class MainForm extends JFrame {
private String fname;
String getthisnow(String usrname) {
this.fname = usrname;
return fname;
}
public MainForm() {
initComponents();
txt_HomeWelcome.setText(fname);//JLabel
...
.
}
}
The JLabel
become null
.. :-( It suppose to show the name from the LoginForm, right? Did I miss something?? Please help! >.< I need that fname
from LoginForm. That's my problem.