KickJava   Java API By Example, From Geeks To Geeks.

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


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 JLogTable
10 extends JTable JavaDoc {
11
12
13     DefaultTableCellRenderer JavaDoc eventTypeRenderer;
14     DefaultTableCellRenderer JavaDoc readonlyRenderer;
15     DefaultTableCellRenderer JavaDoc detailsRenderer;
16     DefaultTableCellRenderer JavaDoc errorLogTypeRenderer;
17
18     LogTableModel logData;
19
20     public JLogTable(LogTableModel dm) {
21         super(dm);
22
23         logData = dm;
24         eventTypeRenderer = new DefaultTableCellRenderer JavaDoc();
25         eventTypeRenderer.setForeground(Color.blue);
26         eventTypeRenderer.setFont(new java.awt.Font JavaDoc("Helvetica",
27                                                 java.awt.Font.BOLD, 10));
28
29         detailsRenderer = new DefaultTableCellRenderer JavaDoc();
30         detailsRenderer.setFont(new java.awt.Font JavaDoc("Helvetica",
31                         java.awt.Font.BOLD, 6));
32
33         readonlyRenderer = new DefaultTableCellRenderer JavaDoc();
34         readonlyRenderer.setFont(new java.awt.Font JavaDoc("Arial",
35                         java.awt.Font.PLAIN, 6));
36
37         errorLogTypeRenderer = new DefaultTableCellRenderer JavaDoc();
38         errorLogTypeRenderer.setForeground(Color.red);
39         getTableHeader().setFont(new java.awt.Font JavaDoc("Helvetica",
40                                     java.awt.Font.BOLD, 12));
41     }
42
43     public TableCellRenderer JavaDoc getCellRenderer(int row, int column) {
44
45         if (((String JavaDoc) logData.getValueAt(row, LogTableModel.EVENT_C)).
46           trim().equals(GuiMaster.ERROR_LOG))
47           return errorLogTypeRenderer;
48
49         if (column == LogTableModel.EVENT_C)
50             return eventTypeRenderer;
51         if (column == LogTableModel.DETAILS_C)
52             return detailsRenderer;
53
54         return readonlyRenderer;
55     }
56 }
57
Popular Tags