KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > plugin > EnabledRenderer


1 /*
2  * Created on 06.08.2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package org.columba.core.gui.plugin;
8
9 import java.awt.Component JavaDoc;
10
11 import javax.swing.JCheckBox JavaDoc;
12 import javax.swing.JLabel JavaDoc;
13 import javax.swing.JTable JavaDoc;
14 import javax.swing.SwingConstants JavaDoc;
15 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
16
17
18 /**
19  * @author frd
20  *
21  * To change the template for this generated type comment go to
22  * Window>Preferences>Java>Code Generation>Code and Comments
23  */

24
25 public class EnabledRenderer extends DefaultTableCellRenderer JavaDoc {
26     JCheckBox JavaDoc checkBox = new JCheckBox JavaDoc();
27
28     public EnabledRenderer() {
29         setHorizontalAlignment(SwingConstants.CENTER);
30     }
31
32     /* (non-Javadoc)
33  * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
34  */

35     public Component JavaDoc getTableCellRendererComponent(JTable JavaDoc table, Object JavaDoc value,
36         boolean isSelected, boolean hasFocus, int row, int column) {
37         PluginNode node = (PluginNode) value;
38
39         if (node.isCategory()) {
40             // this node is category folder
41
// -> don't make it editable
42
return super.getTableCellRendererComponent(table, "", isSelected,
43                 hasFocus, row, column);
44         } else {
45             boolean b = node.isEnabled();
46
47             checkBox.setSelected(b);
48             checkBox.setHorizontalAlignment(JLabel.CENTER);
49
50             if (isSelected) {
51                 checkBox.setBackground(table.getSelectionBackground());
52             } else {
53                 checkBox.setBackground(table.getBackground());
54             }
55
56             return checkBox;
57         }
58     }
59 }
60
Popular Tags