I create a JTable using DefaultTablemodel with initially zero row. table is added in a JscollPane table's row increase dynamically according to some events. I provide the size to table using setBounds(int,int,int,int) of JScrollPane. also provide the backgound color using SetBackground(Color) of JTable . Then I want to provide color the entire setBounds(int,int,int,int) area. how to do it? This is normaly fine in the case JButton,JCheckBox etc. But there is a problem in the case of JTable.
I am setting bounds to Srollpane. but I see the background color as gray color. I am sure this is not the background color of Srollpane or the JPanel. Becuase I am setting different background color to Srollpane and JPanel.
As I said before, it's not the table's background you are seeing, but the scroll pane's. Or to be more precise, the background of the scroll pane's viewport. You'll get the effect you want with scroll.getViewport().setBackground(Color.pink), or probably use a color you like better than pink.
btw, is there a reason you are setting the layout manager to null and calling setBounds? This has nothing to do with your background color problem, of course, but I'd prefer something like this [ December 12, 2006: Message edited by: Brian Cole ]