【发布时间】:2016-06-04 21:12:05
【问题描述】:
每个人由于某种原因在执行时出现空指针异常,但我找不到原因,我认为它与 setOnAction 方法有关,但不知道如何修复它。
在查看部分我得到了
public void addButtonListener(EventHandler<ActionEvent> x)
{
login.setOnAction(x);
}
在控制器中
public Controller(View theView,Model theModel)
{
this.theView = theView;
this.theModel = theModel;
this.theView.addButtonListener(new SolListener());
}
控制器内部类:
class SolListener implements EventHandler<ActionEvent>
{
@Override
public void handle(ActionEvent event)
{
String u,p;
try
{
u = theView.getUsername();
p = theView.getPassword();
theModel.zhoda(u, p);
theView.Solution(theModel.getSolution());
}catch (NullPointerException f)
{
}
}
}
由于某种原因,我仍然在
上收到 NullPointerExceptionpublic void addButtonListener(EventHandler<ActionEvent> x)
有什么想法吗?
【问题讨论】:
标签: java model-view-controller javafx-8