That's a question really similar to this previous post of mine.
I need to customize some cell of a JTable, in a way that they would look like a table header cell.
I'm using Nimbus look and feel and I'm trying to retrieve the color of JTable's editor:
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;
}
}
I follow this post to get the name to be supplied to getColor method ("TableHeader.background").
Despite what I've done since now, the color returned isn't the same of my table's header cells.
Do you have any idea?
EDIT:
I noticed that instead of a color it should be a gradient but I can't find the right key to use. I looked this list.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…