• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can i change the JTable row color or font runtime.  RSS feed

 
Muhammad Asghar
Greenhorn
Posts: 6
Firefox Browser Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i change the JTable row color or font runtime.

When i click on a row of JTable, performs some action such as double click , the text color of whole row should be change.
A code example will be very helpful.

Thanks
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to keep track of rows that have been double clicked, then you would need to add a boolean value to the TableModel that you can set when the double click action is performed.

Then you can use the Table Row Rendering approach to change the font or background color as your wish.

To prevent the boolean data from being displayed in the table you will need to get the TableColumnModel from the table and then remove the TableColumn for the boolean value in the model.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!