Thanks for the people who answered my previous questions. I am having a problem with color. I have a JTable in side the JScrollPane. The content of this table is updated based on the user's selection. If the JTable cannot take all space of the JScrollPane, the unused part of the pane is grey and the table is white. How can I make them the same color white? I tried to set the JScrollPane color as follows JTable table = new JTable(myTabModel); JScrollPane tableScroller = new JScrollPane(table); tableScroller.setForeground(Color.white); tableScroller.setBackground(Color.white); Do not work. Thanks!
Joined: Aug 04, 2003
use setPreferredScrollableViewportSize() on JTable to avoid taking extra space. set the dimensions to Min. dimension of JTable.
Joined: Apr 02, 2003
From the JScrollPane javadoc: A common operation to want to do is to set the background color that will be used if the main viewport view is smaller than the viewport, or is not opaque. This can be accomplished by setting the background color of the viewport, via scrollPane.getViewport().setBackground(). The reason for setting the color of the viewport and not the scrollpane is that by default JViewport is opaque which, among other things, means it will completely fill in its background using its background color. Therefore when JScrollPane draws its background the viewport will usually draw over it.
Joined: Aug 07, 2003
Hi Yijay and Tim: Thanks for your help. It works !