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 JLogTable 10 extends JTable { 11 12 13 DefaultTableCellRenderer eventTypeRenderer; 14 DefaultTableCellRenderer readonlyRenderer; 15 DefaultTableCellRenderer detailsRenderer; 16 DefaultTableCellRenderer errorLogTypeRenderer; 17 18 LogTableModel logData; 19 20 public JLogTable(LogTableModel dm) { 21 super(dm); 22 23 logData = 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 readonlyRenderer.setFont(new java.awt.Font ("Arial", 35 java.awt.Font.PLAIN, 6)); 36 37 errorLogTypeRenderer = new DefaultTableCellRenderer (); 38 errorLogTypeRenderer.setForeground(Color.red); 39 getTableHeader().setFont(new java.awt.Font ("Helvetica", 40 java.awt.Font.BOLD, 12)); 41 } 42 43 public TableCellRenderer getCellRenderer(int row, int column) { 44 45 if (((String ) 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 |