JTable编辑模式可以在任何地方关闭clickng

JTable编辑模式可以在任何地方关闭clickng

本文介绍了JTable编辑模式可以在任何地方关闭clickng的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有两个表.左表就像一个列表.单击左表将打开一个右表,其中包含基于我单击左表的字段的值.

I have a two table in my application. Left table is like a list. Clicking on left table will open a right table, which containing the values based which field I click on left table.

现在的问题是,如果我在右表中编辑一个单元格,而不按Enter键并单击左表中的新项目,则所有表中的特定单元格都处于可编辑模式.还有所有表的单元格的值.

Now the problem is that if I edit a cell in right table and not pressing the Enter key and clicked to the new item in left table,the particular cell in editable mode in all the table.Also the value of the cell going to all the tables.

如何解决该问题?

推荐答案

不完全确定我了解您的经验与期望,但是表的默认行为 有点出乎意料,因为它不会当焦点移到表格外部某处时,请勿进行正在进行的编辑.要在导航到另一个组件时强制提交已编辑的值,必须使用以下命令配置表:

Not entirely sure that I understand what you experience vs what you expect, but table's default behaviour is a bit unexpected in that it doesn't commit an ongoing edit when the focus goes somewhere to the outside of the table. To force committing the edited value when navigating to another component, you have to configure the table with:

table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

这篇关于JTable编辑模式可以在任何地方关闭clickng的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 13:14