比如一个JDialog类
HostBox extends JDialog implements ActionListener它的构造函数,引用待更新的类MainBox
public HostBox(MainBox mainbox)事件监听函数好像无法更新MainBox的数据
(注,在myeclipse没有错误提示,只有在编译的时候才出现
java.lang.NullPointerException错误)public void actionPerformed(ActionEvent e){
HostBean innerhost=new HostBean();
innerhost.setHost(hosttextfield.getText().trim());
innerhost.setUsername(usernametextfield.getText().trim());
innerhost.setPassword(passwordtextfield.getText().trim());
String info;
if((info=HostBean.checkValid(innerhost))!=null){
JOptionPane.showMessageDialog(null,info,"警告",JOptionPane.ERROR_MESSAGE);
return;
}
this.mainbox.setHost(innerhost);
this.mainbox.setFlag(1);
dispose();
}