[英]Checkbox column editing on JTable
I have a JTable
in which one column is a checkbox. 我有一个JTable
,其中一列是一个复选框。 I want to let the user edit the checkbox by mouse drag: if they clicked one checkbox and drag mouse into other checkbox, they will get the same result with the first checkbox clicked. 我想让用户通过鼠标拖动来编辑复选框:如果他们单击了一个复选框,然后将鼠标拖动到另一个复选框中,则他们将在单击第一个复选框时得到相同的结果。
One approach is to specify ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
for the table's selection model, as shown here . 一种方法是指定ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
为表的选择模型,如图所示这里 。 Click and drag to select contiguous rows, or add the shift , control or command modifiers to select disparate rows. 单击并拖动以选择连续的行,或添加shift , Control或Command修饰符以选择不同的行。 In a suitable Action
, update the TableModel
to reflect the selection, as shown here . 在合适的Action
,更新TableModel
以反映该选择,如图所示在这里 。 The JTable
will update itself in response. 作为响应, JTable
将更新自身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.