• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing Colour of JPanel That has JTable  RSS feed

 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to change the colour of my JPanel. Currently the JPanel has a JTable added. This JTable displays rows of data....depending on how much data it has to display (so sometimes 10 rows, sometimes 3 rows somtimes 0 rows etc). However, the background (ie the area that is not taken up by JTable rows) is at the moment the default look and feel colour of Windows (ie that browny colour!). I want to change this to white. I don't want to disable the look and feel because i like it in other aspects of the GUI. Anybody know how i can simply change this background to white!?

I've tried panel.setBackground(Color.WHITE) etc but this doesn't seem to have any effect. Do i perhaps need to change something with my JTable, or table model?! Any suggestions would be greatly appreciated!
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IIRC in Swing you must perform these operations on the content pane, not the component itself. Try:

panel.getContentPane().setBackground(Color.WHITE)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!