KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > calendar > ui > list > DefaultBooleanRenderer


1 package org.columba.calendar.ui.list;
2
3 import java.awt.Component JavaDoc;
4
5 import javax.swing.BorderFactory JavaDoc;
6 import javax.swing.JCheckBox JavaDoc;
7 import javax.swing.JTable JavaDoc;
8 import javax.swing.SwingUtilities JavaDoc;
9 import javax.swing.table.TableCellRenderer JavaDoc;
10
11 import org.columba.calendar.base.api.ICalendarItem;
12
13 //The contents of this file are subject to the Mozilla Public License Version 1.1
14
//(the "License"); you may not use this file except in compliance with the
15
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
16
//
17
//Software distributed under the License is distributed on an "AS IS" basis,
18
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19
//for the specific language governing rights and
20
//limitations under the License.
21
//
22
//The Original Code is "The Columba Project"
23
//
24
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
25
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
26
//
27
//All Rights Reserved.
28

29 /**
30  *
31  *
32  * @author fdietz
33  */

34
35 public class DefaultBooleanRenderer extends JCheckBox JavaDoc implements
36         TableCellRenderer JavaDoc {
37
38     public DefaultBooleanRenderer() {
39
40         //setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
41

42         setHorizontalAlignment(SwingUtilities.CENTER);
43     }
44
45     public Component JavaDoc getTableCellRendererComponent(JTable JavaDoc table, Object JavaDoc value,
46             boolean isSelected, boolean hasFocus, int row, int column) {
47
48         ICalendarItem item = (ICalendarItem) value;
49
50         if (isSelected) {
51             setForeground(table.getSelectionForeground());
52             setBackground(table.getSelectionBackground());
53         } else {
54             setForeground(table.getForeground());
55             setBackground(table.getBackground());
56
57         }
58
59         //setBackground(item.getColor());
60

61         setSelected(item.isSelected());
62
63         return this;
64     }
65
66 }
67
Popular Tags