简体   繁体   English

JAVA:按下按钮时,JCheckBox在JTable中丢失选择

[英]JAVA: JCheckBox lost selection in a JTable when Button pressed

I have this problem: added a jcheckbox in a jtable . 我有这个问题:在jtable中添加了一个jcheckbox In my model this jcheckbox is loaded with getValueAt and used the method setValueAt when selected by the user. 在我的模型中,此jcheckbox装有getValueAt并在用户选择时使用了setValueAt方法。

No problem until I push the confirm button, when all my row selected (true value) disappear and the loop doesn't read anything with true value. 直到我按下确认按钮,当我选择的所有行(真实值)消失并且循环不读取任何具有真实值的东西时,才没问题。

Where is my mistake? 我的错误在哪里? How can I update the model before pressing my confirmation button? 按下确认按钮之前如何更新模型?

Sounds like you are looking for: 听起来您正在寻找:

table.putClientProperty("terminateOnFocusLost", true);

This tells the table to try to commit any ongoing edits when the focus is transfered to the outside, that is to a component which is not a child of the table. 这告诉表在焦点转移到外部(即,不是表的子级的组件)到外部时尝试提交所有正在进行的编辑。

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

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