使用ScrollBar摆动JTable-标头和轨道之间的正方形颜色 [英] swing JTable with ScrollBar - color of square between headers and track

查看:70
本文介绍了使用ScrollBar摆动JTable-标头和轨道之间的正方形颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有BasicScrollBarUI的JTable,我设置了标题背景色:table.getTableHeader().setBackground(GuiConstants.backgroundColor);

I have a JTable with BasicScrollBarUI, I set the headers background color: table.getTableHeader().setBackground(GuiConstants.backgroundColor);

和滚动条的背景色: 公共类ScrollBarUI扩展了BasicScrollBarUI {

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?

谢谢

推荐答案

如何使用滚动窗格:提供自定义装饰 ,您可以使用滚动窗格的setCorner()方法添加彩色的Component:

JPanel panel = new JPanel();
panel.setBackground(Color.gray);
scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, panel);

您可能必须将面板的不透明度设置为true,您可能需要从当前的外观中选择合适的颜色.感觉使用UIMnager.

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 UIMnager.

这篇关于使用ScrollBar摆动JTable-标头和轨道之间的正方形颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆