1 package com.calipso.reportgenerator.userinterface; 2 import javax.swing.*; 3 import javax.swing.border.Border ; 4 import javax.swing.border.EmptyBorder ; 5 import java.awt.*; 6 7 10 public class CheckDataListCellRenderer extends JCheckBox implements ListCellRenderer{ 11 protected static Border m_noFocusBorder = 12 new EmptyBorder (1, 1, 1, 1); 13 14 18 public CheckDataListCellRenderer (){ 19 super(); 20 setOpaque(true); 21 setBorder(m_noFocusBorder); 22 } 23 32 public Component getListCellRendererComponent(JList list, 33 Object value, int index, boolean isSelected, boolean cellHasFocus){ 34 setText(value.toString()); 35 36 setBackground(isSelected ? list.getSelectionBackground() : 37 list.getBackground()); 38 39 setForeground(isSelected ? list.getSelectionForeground() : 40 list.getForeground()); 41 42 ListDataModel data = (ListDataModel)value; 43 setSelected(data.isSelected()); 44 45 setFont(list.getFont()); 46 setBorder((cellHasFocus) ? 47 UIManager.getBorder("List.focusCellHighlightBorder") 48 : m_noFocusBorder); 49 return this; 50 } 51 } 52 53 | Popular Tags |