Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Rendering JList Elements

Every JList has an installed cell renderer that draws every cell. A class that implements the ListCellRenderer interface provides this renderer. When it's time to draw each cell, the interface's sole method is called. The JList has an installed renderer. The returned renderer provides the specific rendering for that one cell of the JList. The JList uses the rendering to draw the element, and then gets the next renderer. public interface ListCellRenderer {   public Component getListCellRendererComponent(JList list, Object value,     int index, boolean isSelected, boolean cellHasFocus); }