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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -