单击以编辑JTable单元格 [英] Single click to edit a JTable Cell

查看:88
本文介绍了单击以编辑JTable单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,第一次单击时选择了JTable单元格,然后在第二次单击时对其进行了编辑.

currently the JTable cell is selected on first click, and on the second one it is edited.

是否可以在第一次单击时直接对其进行编辑?

Is it possible to directly edit it on the first click?

推荐答案

在DefaultCellEditor api中,有一个名为

In the DefaultCellEditor api there is a method named setClickCountToStart

    DefaultCellEditor singleclick = new DefaultCellEditor(new JTextField());
    singleclick.setClickCountToStart(1);

    //set the editor as default on every column
    for (int i = 0; i < table.getColumnCount(); i++) {
        table.setDefaultEditor(table.getColumnClass(i), singleclick);
    } 

这篇关于单击以编辑JTable单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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