如何将JTable更改为可编辑而不是不同选择? [英] How to changeJTable as editable and not in different selection?

查看:89
本文介绍了如何将JTable更改为可编辑而不是不同选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需在JTable中输入一些详细信息.并将这些详细信息存储在具有特定ID的数据库中.但是,如果我根据ID在我的JTable中检索这些详细信息,那时候JTable应该不允许在其中进行编辑操作.它只是出于查看目的.如何根据用户选择设置Jtable是否可编辑. (插入,搜索)

解决方案

可编辑性主要是通过TableModelisCellEditable方法控制的.

您可以在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更改为可编辑而不是不同选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆