Package: javax.swing.* |
Product: Swing |
Release: 1.0.3 |
Related Links: |
ComboBox
JDialog
JFileChooser
JFrame
JOptionPane
JProgressBar
JScrollPane
JTable
General
JTree
JWindow
KeyStroke
LayeredPane
UIDefaults
|
Comment: |
It;s obvious but here we go! ListCellRenderer lcr = new ListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel l = new JLabel(); l.setText(value.toString()); l.setBackground(isSelected ? Color.red : Color.white); l.setForeground(isSelected ? Color.white : Color.black); return l; } }; getComboBox().setRenderer(lcr); // user code end |