void (final @Nullable HighlightSeverity severity) { DefaultListModel<SeverityBasedTextAttributes> model = new DefaultListModel<>(); List<SeverityBasedTextAttributes> infoTypes = new ArrayList<>(getApplicableSeverities()); SeverityBasedTextAttributes preselection = null; for (SeverityBasedTextAttributes type : infoTypes) { model.addElement(type); if (type.getSeverity().equals(severity)) { preselection = type; } } if (preselection == null && !infoTypes.isEmpty()) { preselection = infoTypes.get(0); } myOptionsList.setModel(model); myOptionsList.setSelectedValue(preselection, true); }