我有这个 JTable,带有一个行标题(在左侧 - 涂成粉红色)。如何在它们之间设置边界线?
我尝试了 setborder 方法,但它只设置外边框,我需要它们之间的空间 - 就像在上列标题中一样。
我怎样才能做到这一点?
编辑: 这是行标题的代码:
static String[] rowHeaders = {
"mc 01", "mc 02", "mc 03", "mc 04", "mc 05",
"mc 06", "mc 07", "mc 08", "mc 09", "mc 10", "mc 11", "mc 12",
"mc 13", "mc 14", "mc 15", "mc 16", "mc 17", "mc 18", "mc 19",
"mc 20", "mc 21", "mc 22", "mc 23", "mc 24", "mc 25", "mc 26",
"Nitris 01", "Nitris 02", "Sound A", "Sound B", "Sound C" };
JList rowHeader;
// CREATING A ROW HEADER
ListModel lm = new AbstractListModel() {
public int getSize()
{
return rowHeaders.length;
}
public Object getElementAt(int index)
{
return rowHeaders[index];
}
};
rowHeader = new JList(lm);
rowHeader.setFixedCellWidth(80);
rowHeader.setFixedCellHeight(myTable.getRowHeight());
rowHeader.setBackground(Color.pink);
rowHeader.setFont(new Font("Ariel", 1, 18));
// rowHeader.setBorder(new LineBorder(Color.BLACK, 1));
DefaultListCellRenderer renderer = (DefaultListCellRenderer)rowHeader.getCellRenderer();
renderer.setHorizontalAlignment(JLabel.CENTER);
myTableScrollPane.setRowHeaderView(rowHeader);
谢谢你
戴夫。