KickJava   Java API By Example, From Geeks To Geeks.

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


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 JAlarmTable
10 extends JTable JavaDoc {
11
12
13     DefaultTableCellRenderer JavaDoc eventTypeRenderer;
14     DefaultTableCellRenderer JavaDoc readonlyRenderer;
15     DefaultTableCellRenderer JavaDoc detailsRenderer;
16     DefaultTableCellRenderer JavaDoc heartbeatTypeRenderer;
17
18     AlarmTableModel alarmData;
19
20     public JAlarmTable(AlarmTableModel dm) {
21         super(dm);
22
23         alarmData = 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
35         heartbeatTypeRenderer = new DefaultTableCellRenderer JavaDoc();
36         heartbeatTypeRenderer.setForeground(Color.green);
37         getTableHeader().setFont(new java.awt.Font JavaDoc("Helvetica",
38                                     java.awt.Font.BOLD, 12));
39     }
40
41     public TableCellRenderer JavaDoc getCellRenderer(int row, int column) {
42
43         if (((String JavaDoc) alarmData.getValueAt(row, AlarmTableModel.EVENT_C)).
44           trim().equals(GuiMaster.HEARTBEAT_ALARM))
45           return heartbeatTypeRenderer;
46
47         if (column == AlarmTableModel.EVENT_C)
48             return eventTypeRenderer;
49         if (column == AlarmTableModel.DETAILS_C)
50             return detailsRenderer;
51
52         return readonlyRenderer;
53     }
54 }
55
Popular Tags