FileDocCategorySizeDatePackage
BookCellRenderer.javaAPI DocExample893Thu Oct 24 20:14:22 BST 2002None

BookCellRenderer

public class BookCellRenderer extends JLabel implements ListCellRenderer

Fields Summary
private static final Color
HIGHLIGHT_COLOR
Constructors Summary
public BookCellRenderer()


      
        setOpaque(true);
        setIconTextGap(12);
    
Methods Summary
public java.awt.ComponentgetListCellRendererComponent(javax.swing.JList list, java.lang.Object value, int index, boolean isSelected, boolean cellHasFocus)

        BookEntry entry = (BookEntry)value;
        setText(entry.getTitle());
        setIcon(entry.getImage());
        if(isSelected) {
            setBackground(HIGHLIGHT_COLOR);
            setForeground(Color.white);
        } else {
            setBackground(Color.white);
            setForeground(Color.black);
        }
        return this;