how to get reference from outside class
hi friends.... im new to java.. i could search many site but i cant find the solution.. my problem is..im using one class its..
class class_name{
JTextField tf=null;
class_name() //constractor
{
tf=new JTextField(10);
tf.setText("Hello");
}
public JTextField getText() //return method
{
rerturn tf;
}
}
when i call the method geText() into another JTextField in another class . i can't get the reference of old JTextField....it show null pointer error.....
here im calling the reference name..
class class_name2{
class_name2()
{
class_name cn=new class_name();
JTextField tf2=cn.getText();
System.out.println(""+tf2.getText());
}
}