Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable - how to set background color

 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a JTable inside a JScrollPane in the main window of my application. Say I add 2 rows to my table the background color is white for those 2 rows but for the rest of my table the background color is gray. How can I set the background color so that the background is white? I've tried setBackground(Color.white) but that doesn't make the gray part white.
Any suggestions?
Thanks,
Frank

[This message has been edited by Frank Hale (edited May 31, 2000).]
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out. All I needed to do was get the JViewport of the JScrollPane my JTable was in and set its background color.
Frank
 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting your solution. I was trying to do this for an hour before I searched JavaRanch and found it.
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem.
I try to always post a solution to a question I ask if I figure it out before somebody helps me.
Take care! Have fun!
 
Brian Snyder
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just did a search and glad you had this here. NICE! So simple, but yet so simple.
 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the solution, I have spent 2 hours on that problem. glad now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic