以下 Codesnipplet 引发nullpointerexception。它由 findByName 方法抛出。看起来找不到 PlayerComponentGroupList 但我不知道为什么。
我怎么能引用生成的组件组?
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())));
...
}