0

Why do I get this runtime ERROR?

Exception in thread "main" java.lang.NullPointerException

at venzo.MVC_Controller.actionListenerMeth(MVC_Controller.java:40)

at venzo.MVC_Controller.(MVC_Controller.java:15)

Here is my code:

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);
   }
}
Community
  • 1
  • 1
Besan Vadim
  • 441
  • 4
  • 8

0 Answers0