问题描述
我只需在JTable中输入一些详细信息.并将这些详细信息存储在具有特定ID的数据库中.但是,如果我根据ID在我的JTable中检索这些详细信息,那时候JTable应该不允许在其中进行编辑操作.它只是出于查看目的.如何根据用户选择设置Jtable是否可编辑. (插入,搜索)
可编辑性主要是通过TableModel
的isCellEditable
方法控制的.
您可以在TableModel
中建立一个设置,当您希望模型为只读时,该设置可以返回false
.
有关更多详细信息,请参见如何使用表 >
i just enter some details in JTable. and store those details in my database with specific id. But if i retrieve those details in my JTable based on id, on that time the JTable should not allow edit operation in it. it just for view purpose. How can i set whether Jtable is editable or not based on user selection. (Insert, Search)
Editability is controlled, primarily, through the isCellEditable
method of the TableModel
.
You could establish a setting within your TableModel
which can return false
when you want the model to be read only.
See How to Use Tables for more details
这篇关于如何将JTable更改为可编辑而不是不同选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!