我已经构建了这个应用程序并尝试运行它,但我无法从JTextField
. 我不知道出了什么问题...这是相关的代码...
构造 JTextFeild:(文件 Main.java)
public class Constructor extends javax.swing.JFrame {
public Constructor() {
initComponents();
}
private void initComponents() {
refernce = new javax.swing.JTextField();
/*Some other code in here*/
}
private javax.swing.JTextField refernce;
/*Some other code in here*/
}
从文本字段中获取数据:(文件 Save.java)
public class Save {
/*Some other code in here*/
private javax.swing.JTextField refernce;
String refernceText = refernce.toString();
}
错误报告:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Save.<init>(Save.java:79)
at Constructor.saveMouseClicked(Constructor.java:444)
at Constructor.access$200(Constructor.java:15)
at Constructor$3.mouseClicked(Constructor.java:210)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
... (it carry on(ask if you need it))
那我哪里错了???也没有语法错误等...