01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.mail.gui.table.plugins;
17:
18: import java.awt.Component;
19:
20: import javax.swing.ImageIcon;
21: import javax.swing.JTable;
22: import javax.swing.SwingConstants;
23: import javax.swing.UIManager;
24: import javax.swing.table.DefaultTableCellRenderer;
25: import javax.swing.table.JTableHeader;
26:
27: public class BooleanHeaderRenderer extends DefaultTableCellRenderer {
28: ImageIcon icon;
29:
30: public BooleanHeaderRenderer(ImageIcon icon) {
31: this .icon = icon;
32:
33: setHorizontalAlignment(SwingConstants.LEFT);
34: }
35:
36: public Component getTableCellRendererComponent(JTable table,
37: Object str, boolean isSelected, boolean hasFocus, int row,
38: int column) {
39: if (table != null) {
40: JTableHeader header = table.getTableHeader();
41:
42: if (header != null) {
43: setForeground(header.getForeground());
44: setBackground(header.getBackground());
45: setFont(header.getFont());
46: }
47: }
48:
49: setBorder(UIManager.getBorder("TableHeader.cellBorder"));
50:
51: setIcon(icon);
52:
53: return this;
54: }
55: }
|