KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > userinterface > CheckDataListCellRenderer


1 package com.calipso.reportgenerator.userinterface;
2 import javax.swing.*;
3 import javax.swing.border.Border JavaDoc;
4 import javax.swing.border.EmptyBorder JavaDoc;
5 import java.awt.*;
6
7 /**
8  * CheckDataListCellRenderer define las propiedaes de cada JCheckBox item
9  */

10 public class CheckDataListCellRenderer extends JCheckBox implements ListCellRenderer{
11   protected static Border JavaDoc m_noFocusBorder =
12       new EmptyBorder JavaDoc(1, 1, 1, 1);
13
14   /**
15    * Crea un objeto CheckDataListCellRenderer y setea las propiedades
16    *
17     */

18   public CheckDataListCellRenderer (){
19       super();
20       setOpaque(true);
21       setBorder(m_noFocusBorder);
22     }
23   /**
24    * Retorna el componente con las propiedades con las cual se quiere visualizar el componente
25     * @param list
26    * @param value
27    * @param index
28    * @param isSelected
29    * @param cellHasFocus
30    * @return
31    */

32   public Component getListCellRendererComponent(JList list,
33       Object JavaDoc 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