JTableHeader表头单元格边框

时间:2011-12-22 16:00:05

标签: java swing jtable tablecellrenderer jtableheader

我正在使用此代码:

Border border = BorderFactory.createLineBorder(Color.green); 
DefaulTableModel dtm= new DefaultTableModel();
dtm.addColumn("Srno.");
dtm.addColumn("Product");
JTable table = new JTable(dtm);
table.getTableHeader().setBackground(new Color(150,255,150));
JTableHeader hed = table.getTableHeader();
hed.setBorder(border);

我想为tableheader的每个单元格添加边框。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

您必须为TableCellRendererTableHeaderexample

设置here