@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // Get the renderer component from parent class JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); // Get icon to use for the list item value Character character = (Character) value; Config.ConfigEntry ce = config.get(character.getName()); Icon icon = null; if (ce == null) { icon = icons.get(NOTOK); label.setToolTipText( "Double-click to enter configuration information for this character, right-click for more options"); } else { if (ce.isOk()) { icon = icons.get(OK); ui.exportAllButton.setEnabled(true); } else { icon = icons.get(NOTOK); } } // Set icon to display for value label.setIcon(icon); return label; }
public IconListRenderer(Config config, TokenLabUI ui) throws IOException { this.ui = ui; this.config = config; icons = new HashMap<Object, Icon>(); icons.put(OK, IconCreator.createImageIcon(CHECK_ICON, OK)); icons.put(NOTOK, IconCreator.createImageIcon(X_ICON, NOTOK)); }