Code
class TransparentHeader extends JLabel implements TableCellRenderer {
private final Border b = BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0,0,1,0,Color.BLACK),
BorderFactory.createEmptyBorder(2,2,1,2));
private final Color alphaZero = new Color(0, true);
@Override public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
this.setText(value!=null?value.toString():"");
this.setHorizontalAlignment(JLabel.CENTER);
this.setOpaque(false);
this.setBackground(alphaZero);
this.setForeground(Color.BLACK);
this.setBorder(b);
return this;
}
}
References