01: package com.calipso.reportgenerator.userinterface;
02:
03: import javax.swing.*;
04: import javax.swing.border.Border;
05: import javax.swing.border.EmptyBorder;
06: import java.awt.*;
07:
08: /**
09: * CheckDataListCellRenderer define las propiedaes de cada JCheckBox item
10: */
11: public class CheckDataListCellRenderer extends JCheckBox implements
12: ListCellRenderer {
13: protected static Border m_noFocusBorder = new EmptyBorder(1, 1, 1,
14: 1);
15:
16: /**
17: * Crea un objeto CheckDataListCellRenderer y setea las propiedades
18: *
19: */
20: public CheckDataListCellRenderer() {
21: super ();
22: setOpaque(true);
23: setBorder(m_noFocusBorder);
24: }
25:
26: /**
27: * Retorna el componente con las propiedades con las cual se quiere visualizar el componente
28: * @param list
29: * @param value
30: * @param index
31: * @param isSelected
32: * @param cellHasFocus
33: * @return
34: */
35: public Component getListCellRendererComponent(JList list,
36: Object value, int index, boolean isSelected,
37: boolean cellHasFocus) {
38: setText(value.toString());
39:
40: setBackground(isSelected ? list.getSelectionBackground() : list
41: .getBackground());
42:
43: setForeground(isSelected ? list.getSelectionForeground() : list
44: .getForeground());
45:
46: ListDataModel data = (ListDataModel) value;
47: setSelected(data.isSelected());
48:
49: setFont(list.getFont());
50: setBorder((cellHasFocus) ? UIManager
51: .getBorder("List.focusCellHighlightBorder")
52: : m_noFocusBorder);
53: return this;
54: }
55: }
|