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
please i want short code for this problem can you please??????
ReplyDeleteHello, saikiranreddy
DeleteI compiled it in 63 rows: TransparentHeaderTest.java