java - use login class from another class -
i create login form , when press button, want pass entered name class.
private void okbuttonactionperformed(java.awt.event.actionevent evt) { get_name = this.namefield.gettext(); get_pass = this.passwordfield.gettext(); }
in class prints null,
public static void main(string[] args) { loginframe logframe = new loginframe(); system.out.println(logframe.get_name); }
the main()
method gets called before get_name
has value set why getting null
. if debug application (or move print
) chances get_name
wont null
after okbuttonactionperformed()
gets called.
also not practice have public variables, should set them private , use getters
, setters
access them instead. here list of reasons so.
Comments
Post a Comment