简体   繁体   English

TableModelListener

[英]TableModelListener

I am making a student record application... I want a column in it which is editable. 我正在制作学生记录申请表......我想要一个可编辑的专栏。 I have attached table model listener on table and on that column im saving all the updating values 我已经在表和该列上附加了表模型侦听器,我保存了所有更新值

if(table.getSelectedColumn() == 3 && table.getSelectedRow() != -1 && tme.getType() ==     TableModelEvent.UPDATE)
{
// my code here
table.cellEditAt(row,column); // this is giving me error
}

table.cellEditAt automatically calls table model event and that is producing a infinite loop... Any other method to automatically select a cell for editing???? table.cellEditAt自动调用表模型事件,并产生无限循环...还有其他方法可以自动选择要编辑的单元格吗?

请发布一个SSCCE来演示您的问题,例如,基于我关于无限循环的问题, 通过链接到我的答案的 工具TabelModelListener

The answer was to post an SSCCE. 答案是发布SSCCE。 We are not mind readers. 我们不介意读者。 We can't guess what your editCellAt(...) method does. 我们无法猜测您的editCellAt(...)方法的作用。 If it causes a loop, then that would be because you are somehow changing the model and generating another TableModelEvent. 如果它导致循环,那将是因为您以某种方式更改模型并生成另一个TableModelEvent。 Don't do this! 不要这样做!

If the problem is somehow related to placing a cell in edit mode, then I would guess you need to wrap that code in a SwingUtilities.invokeLater() to make sure the processing of the original event is completed before you place another cell in edit mode. 如果问题以某种方式与将单元格置于编辑模式有关,那么我猜你需要将该代码包装在SwingUtilities.invokeLater()中,以确保在将另一个单元格置于编辑模式之前完成原始事件的处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM