如何更改JTable的标题背景颜色?
我尝试过:
table.getTableHeader().setBackground(Color.BLACK);
不起作用.
此代码仅在我的项目中不起作用.在其他项目中工作.我可能已经更改了阻止颜色更改的属性.也许NetBeans具有一些保留默认颜色的属性.我注意到了别的东西.我项目中标题的颜色以不同的方式闪烁.在发生颜色变化的示例中,我看到了不同的图形.
This code doesn't work in my project only. Works in other projects. I may have changed a property that stops the color from changing. Or maybe NetBeans has some property which keeps the default colors. I've noticed something else. The color of the header in my project is shining in a different way. In the examples where the color change works, I see different graphics.
其他.我注意到按钮也不会改变颜色.必须是通用的.希望这可以帮助.不幸的是,SSCCE在这种情况下不起作用,因为我无法重现该问题.我肯定使用了正确的组件名称.
EDIT 2: Something else. I noticed that the buttons won't change color either. Must be something generic. Hope this helps. Unfortunately SSCCE won't work in this case, because I can't recreate the problem. I am surely using the right component names.
已解决. 在NetBeans中:
Solved it. In NetBeans:
- 右键单击项目名称
- 属性
- 应用程序-桌面应用程序
- 外观:选择"Java默认值"(不适用于系统默认值")
- 在运行项目之前,请记住清理并重建
整个项目的图形也改变了外观.
Also the graphics of the whole project changed appearance.