所以我有自定义CellEditors和CellRenderers,虽然我正在做
component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
component.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
component.setOpaque(true);
在我的getTableCellRendererCompoent中,颜色只匹配每个OTHER行,因为大部分的hte外观和感觉我似乎已经尝试过它们。如何以与表格其余部分相似的方式拉出颜色值?我也非常希望能够制作漂亮的边框来匹配DefaultTableCellRenderer的渲染器。
我试图剖析DefaultTableCellRenderer,我试图追踪这个UI对象而迷路了。我是否只需要从UIManager获取正确的属性?领导正确的方向将非常受欢迎。
谢谢大家,这个网站摇滚。 约书亚
答案 0 :(得分:4)
是的,您应该使用Swing调色板颜色。例如:
final Color tableBackground = javax.swing.UIManager.getDefaults().getColor("Table.background");
这是表格的颜色键值:
或者,您也可以使用system colors。例如:
正常背景:
SystemColor.window
所选背景:SystemColor.textHighlight
正常前景:SystemColor.text
选择前景:SystemColor.textText