Hey guys.
I’m trying to implement a game browser with nifty but I’m receiving ConcurrentModification exceptions when I’m adding items to the list.
The following is the code where I add game-names to a list.
[java]private void updateGameList() {
ListBoxControl lobbygameList = screen.findControl(“listBoxStatic”, ListBoxControl.class);
//receives a List
List<GamesListGameMessage> gameList=StaticData.getCustomGamesList().getGames();
if (gameList.size() > 0) {
for (GamesListGameMessage e : gameList) {
lobbygameList.addItem(" " + e.getGameId() + "t t "
- e.getHostNick() + "t t" + e.getUserCount() + "/"
- e.getUserMax()); //
}
} else {
lobbygameList.addItem("No games available");
}
}[/java]
and this is the xml part:
[xml]
<panel id="listBoxPanel" childLayout="vertical" width="100%" height="70%" padding="30px,30px,30px,30px">
<control id="listBoxStatic" name="listBox">
<panel id="listBoxStaticData" width="100%" childLayout="vertical" visibleToMouse="true" />
</control>
</panel>
[/xml]
Things I already tried out:
- when I start adding simple integer values to the list (1…10) I receive the exception after the second integer.
- the method doesnt get called twice
Any suggestions would be greatly appreciated.
Kaizo
EDIT: I should add that updateGameList() gets called when I click on a refresh button at the bottom of the screen.