void (FileTemplate selection) { myModel = new MyListModel(); myList.setModel(myModel); for (FileTemplate template : templates) { myModel.addElement(template); } if (selection != null) { selectTemplate(selection); } else if (myList.getModel().getSize() > 0) { myList.setSelectedIndex(0); } }