/** * Return a component that has been configured to display the specified value. * * @param list The JList we're painting. * @param value The value returned by list.getModel().getElementAt(index). * @param index The cells index. * @param isSelected True if the specified cell was selected. * @param cellHasFocus True if the specified cell has the focus. * @return A component whose paint() method will render the specified value. * @todo Implement this javax.swing.ListCellRenderer method */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { HostItem hi = (HostItem) value; JLabel c = new JLabel(hi.name); if (isSelected && hi.eavesDroppingEnabled) { c.setBackground(Color.magenta); c.setForeground(list.getSelectionForeground()); } else if (!isSelected && hi.eavesDroppingEnabled) { c.setBackground(Color.red); c.setForeground(list.getForeground()); } else if (isSelected) { c.setBackground(list.getSelectionBackground()); c.setForeground(list.getSelectionForeground()); } else { c.setBackground(list.getBackground()); c.setForeground(list.getForeground()); } c.setEnabled(list.isEnabled()); c.setFont(list.getFont()); c.setOpaque(true); return c; }