1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
public class ResultTableHeaderRenderer extends JLabel implements TableCellRenderer{
boolean _selected = false;/* true if there is a filter on this column, false else*/
String _columnName;/* the title of the column*/
private static final long serialVersionUID = 24L;
/**
* Constructor
* @param columnName the title of the column
*/
ResultTableHeaderRenderer(String columnName){
super();
_columnName = columnName;
}
/**
* modify the selection
* @param select true to indicate that there is a filter in this column, false else
*/
public void setSelected(boolean select){
_selected = select;
}
/**
* render, write in red the title if the column is selected, else it's in black
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (_selected)
this.setText("<html><font color=red>"+_columnName+"<font></html>");
else
this.setText(_columnName);
return this;
}
} |