最佳答案
您可以使用 TableModel 合并原始 TableModel 的两列来实现 JTable。
class Model2 extends AbstractTableModel
{
private TableModel delegate;
public Model2(TableModel delegate)
{
this.delegate= delegate;
}
public int getRowCount() { return this.delegate.getRowCount();}
public int getColumnCount() { return this.delegate.getColumnCount()-1;}
public Object getValueAt(int row, int col)
{
if(col==0) return ""+delegate.getValueAt(row,col)+delegate.getValueAt(row,col+1);
return delegate.getValueAt(col+1);
}
(...)
}
关于java - 合并 JTable 中的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/476721/