This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable color problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable color problem" Watch "JTable color problem" New topic
Author

JTable color problem

Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150
Hi,

I am using JTable and I have added it to JScrollPane. Now I want to
change color of JTable. I have tried to set background of both table and
scrollpane but it didn't work. If table has two row it will have default
color but remaining table should have white background.


Any Help...


~ Anand,
SCJP 1.5, SCWCD 1.5
Trushant Patil
Greenhorn

Joined: Apr 13, 2006
Posts: 7
hi
to change the backgroud of the whole table implement this
--> table.setBackground(Color.red);

If you would like that the filled rows sholud have different colors from the one that are empty then you have to write another class implementing TableCellRenderer and then call

TableCellRenderer renderer = new MytableRenderer();
table.setDefaultRenderer(Object.class, renderer);

and in this overload function "getTableCellRendererComponent(..)" where in you can specify color for each row.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable color problem
 
Similar Threads
Highlighting a JTable cell on a successful search for a value entered in a textfield.
JTable cells
JTable
JTable
JTable