1 package ist.coach.coachEmfClientComponents.gui; 2 3 import javax.swing.JTable ; 4 import javax.swing.table.DefaultTableCellRenderer ; 5 import javax.swing.table.TableCellRenderer ; 6 import javax.swing.table.TableModel ; 7 import java.awt.Color ; 8 9 public class JAlarmTable 10 extends JTable { 11 12 13 DefaultTableCellRenderer eventTypeRenderer; 14 DefaultTableCellRenderer readonlyRenderer; 15 DefaultTableCellRenderer detailsRenderer; 16 DefaultTableCellRenderer heartbeatTypeRenderer; 17 18 AlarmTableModel alarmData; 19 20 public JAlarmTable(AlarmTableModel dm) { 21 super(dm); 22 23 alarmData = dm; 24 eventTypeRenderer = new DefaultTableCellRenderer (); 25 eventTypeRenderer.setForeground(Color.blue); 26 eventTypeRenderer.setFont(new java.awt.Font ("Helvetica", 27 java.awt.Font.BOLD, 10)); 28 29 detailsRenderer = new DefaultTableCellRenderer (); 30 detailsRenderer.setFont(new java.awt.Font ("Helvetica", 31 java.awt.Font.BOLD, 6)); 32 33 readonlyRenderer = new DefaultTableCellRenderer (); 34 35 heartbeatTypeRenderer = new DefaultTableCellRenderer (); 36 heartbeatTypeRenderer.setForeground(Color.green); 37 getTableHeader().setFont(new java.awt.Font ("Helvetica", 38 java.awt.Font.BOLD, 12)); 39 } 40 41 public TableCellRenderer getCellRenderer(int row, int column) { 42 43 if (((String ) 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 |