为什么我会收到此运行时错误?
线程中的异常" main"显示java.lang.NullPointerException
at venzo.MVC_Controller.actionListenerMeth(MVC_Controller.java:40)
在venzo.MVC_Controller。(MVC_Controller.java:15)
这是我的代码:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
public class MVC_Controller implements ActionListener
{
MVC_Model model;
MVC_View view;
public MVC_Controller(MVC_View v,MVC_Model m)
{
model=m;
view=v;
actionListenerMeth(this);//add action listener to the Button
}
@Override
public void actionPerformed(ActionEvent arg0) {
try
{
//retrieve the input from View
String a=view.username.getText();
String b=view.password.getText();
//call add method
String result=model.login_meth(a,b);
//display result in View(UI)
view.result_lb.setText(""+result);
}
catch(Exception ee)
{
ee.printStackTrace();
}
}
public void actionListenerMeth(ActionListener ae)
{
view.login_bt.addActionListener(ae);
}
}