禁用 JTable 上的用户输入
有没有办法在创建 JTable 之后禁用对其进行编辑。 因为我的 JTable 是使用 GUI 工具自动创建的,所以我无法编辑创建 JTable 的源代码。
干杯
Is there a way to disable editing a JTable after creating it.
Because my JTable is created automaticly using GUI Tools and I cannot edit the source code where it creates the JTable.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,但它在您的 TableModel 中。有一个名为 isCellEditable 如果你无法操作你的模型,可以尝试这样的事情:
你的对象必须被创建!这是一个有点令人困惑的代码。您正在创建一个匿名类。
请记住,当您谈论“编辑”时,您实际编辑的是存储在该表中的数据。数据在 TableModel 中表示。
Yes, but it's in your TableModel. There's a method called isCellEditable If you can't manipulate your model, can try something like this:
Your object must be created! It's a little confusing code. There you're creating an anonymous class.
Remember, when you talk about "editing", what you're actually editing, is the data stored in that table. The data is represented in the TableModel.
如果您可以访问源代码,并且有对框架的引用,您仍然可以以编程方式遍历容器树,直到到达表,然后调用您需要的任何内容。
If you have access to the source code, and have a reference to the frame, you could still programatically traverse the container tree until you get to the table, then call whatever you need on it.