如何在 JTable 中使行可编辑(假) [英] How to make the row editable(false) in JTable
本文介绍了如何在 JTable 中使行可编辑(假)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
如何使 JTable 不可编辑
我正在使用 Netbeans 开发应用程序.
I am developing an application using Netbeans.
我生成了 JTable 格式的报告.
I have generated a Report in a JTable format.
它工作正常,但行和列是可编辑的,我希望它们不可编辑.
It works properly but the rows and colums are editable, and I would them to be non-editable.
推荐答案
在您的表模型中,您可以覆盖 isCellEditable()
方法:
In your table model you can override the isCellEditable()
method:
public class MyModel extends DefaultTableModel
{
public MyModel(Object[][] data, Object[] cols)
{
super(data, cols);
}
public boolean isCellEditable(int row, int col)
{
return false;
}
}
这篇关于如何在 JTable 中使行可编辑(假)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文