I have a JTable with BasicScrollBarUI, I set the headers background color: table.getTableHeader().setBackground(GuiConstants.backgroundColor);
and the scrolbar background color: public class ScrollBarUI extends BasicScrollBarUI {
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
c.setBackground(GuiConstants.backgroundColor);
}
}
I still have a square between them that its color won't change. does anybody knows how to change it also to their color?
thanks
As shown in How to Use Scroll Panes: Providing Custom Decorations, you can use the scroll pane's setCorner()
method to add a colored Component
:
JPanel panel = new JPanel();
panel.setBackground(Color.gray);
scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, panel);
You may have to set the panel's opacity to true
, and you may want to select a suitable color from the the current Look & Feel using the UIManager
.