I am trying to pass/set the text from one jtextfield in a jframe (jTF1) to another jtextfield that is in another jframe (jTF2). But, after running the code, I am encountering an error that is mentioned above which means that the text from jTF1 can't be set to jTF2
This is Student_Dash class:-
public class Student_Dash extends JFrame {
Connection con=null;
ResultSet rs=null;
Statement stmt;
public JPanel contentPane = new JPanel();;
JPanel Profile = new JPanel();
private JTable table;
private JTextField nameTA;
private JTextField idTF;
private String str;
/**
* Launch the application.
*/
public static void main(String args[]){
new Student_Dash();
}
public void my_update(String s) { //using this code to set value from textfield1 to idTF
idTF.setText(s); //here the error is occurring
}
/* rest code,
till the end */
}
and I am passing the text value using a variable, from homepage class through this code:-
public class homepage extends JFrame {
Student_Dash stdash=new Student_Dash();
String userid=textField.getText(); //getting value from textfield1
stdash.my_update(userid);
stdash.setVisible(true);
}