This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is it possible to change the colour of the JTable Cell Dynamically ?
i have set different colour for certain rows by overriding the prepareRenderer (TableCellRenderer renderer, int index_row, int index_col) in the JTable as below:
and now i have to set different colours for certain cells according to some condition what should i do for that ?
i tried by extending the DefaultTableCellRenderer class as below:
Sorry i was not able to give different colors to certain rows by custom TableCellRenderer..could you please give an example to do it.
before i was able to colour certain rows using prepareRenderer.but the problem was that i was not able to colour certain cells after that by using custom TableCellRenderer...can you please help me out..
Joined: Jul 04, 2010
Hi pete stein ,
sorry to say that i was not able to change the cell color in JTable using the custom TableCellRenderer. but i can see the changed color only when i am selecting the cells..what i have to do to see the colour without selecting the coloured cells..
the code which iam using is given below.
For better help sooner, post a properly formatted SSCCE using the code tags.
There are no new questions, but there may be new answers.
Joined: Jul 04, 2010
Hi Darryl Burke,
I have posted the code above..i will explain my problem first.
I have to give different colours for certain rows in the table according to certain condition..
after that i have to colour certain cells as red for showing that it is locked..and also user have to lock the new cells by changing its color to red while clicking an button..
I have set different colour for certain rows by overriding the prepareRenderer (TableCellRenderer renderer, int index_row, int index_col) in the JTable as below: