I wanna want to pass or share data(values) from login frame to all frames in my project, H have made class of this variables like this
public class SharedData {
public String LoginName;
public SharedData() {
}
/**
* @return the LoginName
*/
public String getLoginName() {
return LoginName;
}
/**
* @param LoginName the LoginName to set
*/
public void setLoginName(String LoginName) {
this.LoginName = LoginName;
}
}
and from the first frame (login frame) I make object of this class and sets its username like this
public SharedData data1=new SharedData();
data1.setLoginName(Username_Login.getText().toString());
and from the second frame i get the value :
public SharedData data=new SharedData();
ogin_labelName.setText(data1.getLoginName().toString());
But finally it doesn’t work … what is the problem or any solution ?
thanks in advance
You can create a bean class like :
And use this class for setting and getting a values from another form just calling this class for setting a value:
and for getting a value :