【发布时间】:2011-10-02 10:49:37
【问题描述】:
这个问题与我的previous post 非常相似。 我需要自定义 JTable 的某些单元格,使其看起来像表格标题单元格。 我正在使用 Nimbus 外观和感觉,我正在尝试检索 JTable 编辑器的颜色:
public class HeaderCellRenderer extends JLabel implements TableCellRenderer{
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
System.out.println("OK");
this.setOpaque(true);
setBackground(UIManager.getColor("TableHeader.background"));
return this;
}
}
我按照post 获取要提供给 getColor 方法的名称(“TableHeader.background”)。 尽管我从现在开始做了什么,但返回的颜色与我的表格标题单元格的颜色不同。
你有什么想法吗?
编辑:
我注意到它应该是渐变而不是颜色,但我找不到要使用的正确键。我看了this list。
【问题讨论】:
标签: swing colors header jtable look-and-feel