以下Codesnipplet將引發一個nullpointerexception。它由findByName方法拋出。看起來像找不到PlayerComponentGroupList,但我不知道爲什麼。findByName NullPointerException
我該如何參考生成的componentgroup?
protected void beforeMain(Form f) {
super.beforeMain(f);
try {
findPlayerComponentGroup(f).addComponent(getItems("Player"));
} catch (IOException ex) {
throw new RuntimeException(ex.getMessage());
}
}
private Container getItems(String order) throws IOException {
...
final Container rows = new ComponentGroup();
...
rows.setName("PlayerComponentGroupList");
return rows;
}
protected void onMain_PlayerContainerButtonSortNameAction(Component c, ActionEvent event) {
super.onMain_PlayerContainerButtonSortNameAction(c, event);
try {
findPlayerComponentGroup().removeComponent(findByName("PlayerComponentGroupList", Display.getInstance().getCurrent())));
...
}
哪個方法拋出異常?爲什麼不在調試器中運行它並查看返回null的內容? – 2013-02-20 08:57:28
對不起,沒有制定這個popper:findByName ....修正了問題 – Megachip 2013-02-20 13:39:19