【发布时间】:2013-07-16 21:41:40
【问题描述】:
我在使用这个 JTable 时遇到了问题。我像这样编辑一个单元格
然后我按 Enter 提交更改。在这里,我希望表 gui 用新值刷新。
但它们不显示,它们仅在我像这样更改选择时显示
fireTableCellUpdated( inRow, inCol ); 是我编辑单元格时在tableModel 中的方法调用。
我不确定当 fireTableCellUpdated 到 jtable 以重新绘制和重新验证时是否必须向 tableModel 添加侦听器。
一些代码:
这在 tableModel 中被调用。
@Override
public void setValueAt( Object inValue, int inRow, int inCol ) {
ProductRow productRow = (ProductRow)( getRowsData().get(inRow) );
//more code
productRow.setCantidad( inValue.toString() ); // when this is called all properties are updated from ProductRow
fireTableCellUpdated( inRow, inCol );
}
【问题讨论】:
-
你能告诉我们这张桌子的代码吗?
-
mm 我不太确定我应该显示什么代码。我发布了表格模型,当我编辑单元格时会调用此方法
标签: java swing jtable abstracttablemodel