void (T item, @NlsContexts.Checkbox String text, boolean selected) { JCheckBox checkBox = new JCheckBox(text, selected); checkBox.setOpaque(true); // to paint selection background myItemMap.put(item, checkBox); //noinspection unchecked ((DefaultListModel)getModel()).addElement(checkBox); }