package cz.muni.fi.bronchus.gui; /* * MyRespCellRenderer.java * * Created on November 18, 2004, 4:19 PM */ import javax.swing.*; import javax.swing.table.*; import java.awt.Color; import java.awt.Component; import cz.muni.fi.bronchus.questions.ResProcessingItem; /** * * @author xudrzal */ public class MyRespCellRenderer extends JLabel implements TableCellRenderer { private static final Color GENERATED_ELEMENT = Color.LIGHT_GRAY; private static final Color NEW_ELEMENT = Color.WHITE; public MyRespCellRenderer() { setOpaque(true); //MUST do this for background to show up. setFont(new java.awt.Font("Dialog", 0, 11)); } public Component getTableCellRendererComponent(JTable table, Object object, boolean isSelected, boolean hasFocus, int row, int column) { ResProcessingItem s = (ResProcessingItem)object; if (isSelected) { setBackground(table.getSelectionBackground()); } else { if (s!=null) setBackground( s.isGenerated() ? GENERATED_ELEMENT : NEW_ELEMENT ); else setBackground(table.getBackground()); } if (s!=null) setText(s.getCondition()); if (s!=null) setToolTipText(s.getCondition()); return this; } }