Im trying to get jTextField value in another class but always get error null exception. Here is my code :
Class Main :
public class FormTambahDoc extends javax.swing.JFrame {
Utility utility;
public FormTambahDoc() {
initComponents();
utility = new Utility();
setButton();
}
public String gettextIdentitasPengguna() {
return textIdentitasPengguna.getText();
}
private void setButton() {
btnSimpan.addActionListener(new ActionListener() {@Override
public void actionPerformed(ActionEvent e) { utility.cek();} });
}
}
Class another:
public class Utility {
FormTambahDoc formTambahDoc;
//FileJpaController controller;
public void cek()
{
String inputText = formTambahDoc.gettextIdentitasPengguna();
System.out.println(inputText);
//return `Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException`
}
}
What's wrong in this code ?