Hi
I have created a java swing application. In which I am using JTable.
When creating a simple JTable and displaying with Nimbus, the row background color alternates between white and a light blue-grey.
I want the table with single colour. Only the first column should be grey colour and other should be white.
I used this code to set the background and foreground colour.
public Component prepareRenderer
(TableCellRenderer renderer, int index_row, int index_col){
Component objComponent = super.prepareRenderer(renderer, index_row, index_col);
Color objGreyColour = new Color(240,240,240);
Color objWhiteColour = new Color(255,255,255);
if(index_col == 0){
objComponent.setBackground(objGreyColour);
objComponent.setFont(new java.awt.Font(CommonClass.getFontName(),java.awt.Font.BOLD, CommonClass.getFontSize()));
objComponent.setForeground(Color.BLACK);
}else{
setSelectionBackground(Color.BLUE);
objComponent.setBackground(objWhiteColour);
objComponent.setForeground(Color.BLACK);
}
return objComponent;
}
Look wise it is fine but when i try to select the cell it is not highlighting the cell and also i m not able to select multiple cell with ctrl key.
Any help would be appreciated
Thanks
Sonal