java - JTable 鼠标监听器无法正常工作

标签 java swing concurrency jtable mouselistener

我的 JTable (jtblLot) 鼠标单击事件有时不会触发。主要看频繁点击

鼠标点击事件代码如下

 private void jtblLot_MouseClicked(java.awt.event.MouseEvent evt) {       

    int row = jtblLot.rowAtPoint(evt.getPoint()), currId = 0;
    int col = 3;

    lotId = jtblLot.getValueAt(row, col).toString();
    if (jtblLot.getValueAt(row, 1) != null) {
    sizeGrp_up = jtblLot.getValueAt(row, 1).toString();
    } else {
    sizeGrp_up = "0";
    }

    if (jtblLot.getValueAt(row, 4) != null) {
    if (jtblLot.getValueAt(row, 4).toString().compareTo("") !=0)
    {
    currId = Integer.parseInt(jtblLot.getValueAt(row, 4).toString()) - 1;
    }
    } else {
    sizeGrp_up = "0";
    }

    cmbCurrency.setSelectedIndex(currId);
    jlblLotId.setText(lotId);

    // Sets Model For Another JTable(jtblLGP) In My Form Get Data From DB
    getLotGradePriceData();

    //On Click I get The Focus To The Clicked Cell
    int col_ = jtblLot.columnAtPoint(evt.getPoint());
    jtblLot.setCellSelectionEnabled(true);
    jtblLot.changeSelection(row, col_, false, false);
    jtblLot.scrollRectToVisible(new Rectangle(jtblLot.getCellRect(row, col_, true)));

} 

最佳答案

如果您需要处理每次点击,我建议您处理 mouseReleased 而不是 mouseClicked

关于java - JTable 鼠标监听器无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15613846/

相关文章:

java - 使用 GridLayout - 如何设置 JPanel 大小?

java - Active Directory - 通过指定搜索过滤器和搜索控件进行搜索,无需上下文

java - 应用程序启动时图像超出 imageview

java - 不在 JPanel 中显示添加到另一个 JPanel 的图形

java - 我的 Jtable 不刷新

Java this.dispose 调用时不关闭窗口

java - 如何让大组件在使用JGoodies FormLayout时不至于炸毁布局?

c# - ConcurrentBag - 添加多个项目?

java - ForkJoinPool 并行度=1 死锁

javascript - 关于node.js中的MySQL模块以及与mySQL数据库的并发连接