Working with JList
Hi,
I'm trying to do a categorization in my application.
Ideally, I have a list of (String) season's name and a list of Recipe objects. What I'm trying to do is that, each time I select a season name, I want the application to show all the Recipes that matched the season name.
Below is what I've written, but somehow it's giving meNullPointerException I dont understand it cos it was working the first time.
publicvoid jSeasonList_valueChanged(ListSelectionEvent e){
try{
resultList.removeAllElements();//clear result list
//get selected season name
String aSeason = (String) seasonList.get(jSeasonList.getSelectedIndex());
for (int i = 1; i < recipeList.size(); i++){
//go through recipe list
Recipe aRecipe = (Recipe) recipeList.get(i);
if (aRecipe.getSeason().equals(aSeason))
//if selected season match the one on the recipe, add to result
resultList.add(aRecipe);
}
jResultList.setListData(resultList);//update list
}
catch(NullPointerException ne){
System.out.println("Unknown Error!?");
}
}
Any helps n suggestions would be much appreciated!

