1 16 package org.apache.log4j.lf5.viewer; 17 18 import org.apache.log4j.lf5.LogLevel; 19 import org.apache.log4j.lf5.LogRecord; 20 21 import javax.swing.*; 22 import javax.swing.table.DefaultTableCellRenderer ; 23 import java.awt.*; 24 25 32 33 35 public class LogTableRowRenderer extends DefaultTableCellRenderer { 36 40 protected boolean _highlightFatal = true; 44 protected Color _color = new Color(230, 230, 230); 45 46 50 54 58 public Component getTableCellRendererComponent(JTable table, 59 Object value, 60 boolean isSelected, 61 boolean hasFocus, 62 int row, 63 int col) { 64 65 if ((row % 2) == 0) { 66 setBackground(_color); 67 } else { 68 setBackground(Color.white); 69 } 70 71 FilteredLogTableModel model = (FilteredLogTableModel) table.getModel(); 72 LogRecord record = model.getFilteredRecord(row); 73 74 setForeground(getLogLevelColor(record.getLevel())); 75 76 return (super.getTableCellRendererComponent(table, 77 value, 78 isSelected, 79 hasFocus, 80 row, col)); 81 } 82 83 84 protected Color getLogLevelColor(LogLevel level) { 88 return (Color) LogLevel.getLogLevelColorMap().get(level); 89 } 90 91 95 99 } 100 101 102 103 104 105 106 | Popular Tags |