KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > gui > JAttributesTable


1 package ist.coach.coachEmfClientComponents.gui;
2
3 import javax.swing.JTable JavaDoc;
4 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
5 import javax.swing.table.TableCellRenderer JavaDoc;
6 import javax.swing.table.TableModel JavaDoc;
7 import java.awt.Color JavaDoc;
8
9 public class JAttributesTable
10 extends JTable JavaDoc {
11
12     DefaultTableCellRenderer JavaDoc editableRenderer;
13     DefaultTableCellRenderer JavaDoc readonlyRenderer;
14     DefaultTableCellRenderer JavaDoc attributeNameRenderer;
15
16     public JAttributesTable(TableModel JavaDoc dm) {
17         super(dm);
18         readonlyRenderer = new DefaultTableCellRenderer JavaDoc();
19         readonlyRenderer.setForeground(Color.gray);
20
21         editableRenderer = new DefaultTableCellRenderer JavaDoc();
22
23         attributeNameRenderer = new DefaultTableCellRenderer JavaDoc();
24         attributeNameRenderer.setForeground(Color.blue);
25         attributeNameRenderer.setFont(new java.awt.Font JavaDoc("Helvetica",
26                                                 java.awt.Font.BOLD, 12));
27
28         getTableHeader().setFont(new java.awt.Font JavaDoc("Helvetica",
29                                     java.awt.Font.BOLD, 14));
30     }
31
32     public TableCellRenderer JavaDoc getCellRenderer(int row, int column) {
33
34         if (column == 0)
35             return attributeNameRenderer;
36
37         if (getModel().isCellEditable(row, column))
38             return editableRenderer;
39         else
40             return readonlyRenderer;
41     }
42 }
43
Popular Tags