I'm trying to change the background color of header
of JTable
.
With this code I was able to:
public Principal() throws UnsupportedLookAndFeelException {
initComponents();
jTable.getTableHeader().setDefaultRenderer(new HeaderColor());
}
static public class HeaderColor extends DefaultTableCellRenderer {
public HeaderColor() {
setOpaque(true);
}
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean selected, boolean focused, int row, int column) {
super.getTableCellRendererComponent(jTable, value, selected, focused, row, column);
setBackground(new java.awt.Color(255,255,255));
return this;
}
}
This is the result you expected, however, without the border in the header. I need this border.
Is there any way to change this code to insert the border?