|
Hi!
I'm the beginer and have a problem while coloring rows in my table. The problem is as follows:
i need to color the whole row when i click a single cell of this row. Everything is ok until i click another cell of another row. When i do it all the row between first and last clicked become colored!
I tryed manipulating table.setSelectionMode(i) - but nothing!
My very simple code:
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer()
{
public Component getTableCellRendererComponent(JTable table,Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent(table,value, isSelected, hasFocus, row, column);
if (isSelected) {cell.setBackground(Color.LIGHT_GRAY);return cell;}
return cell;
}
};
for(int i=0; i<table.getColumnCount(); i++)
{
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
}
Please help!
PS I cant use Ctrl button in my program because all the changes in table are in table.isEnable(false)-mode-it is the condition of my work.
|
|
|
|
|
|
|
// |