JTable - Selected Row click event

前端 未结 5 995
名媛妹妹
名媛妹妹 2021-02-02 09:36

I have a Jtable that is populated with a linkedlist through an AbstractTableModel.

What I want to do is when I click (left-mouse click) on a row in the JTable, the linke

5条回答
  •  春和景丽
    2021-02-02 09:47

     private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {                                     
         JTable source = (JTable)evt.getSource();
                int row = source.rowAtPoint( evt.getPoint() );
                int column = source.columnAtPoint( evt.getPoint() );
                String s=source.getModel().getValueAt(row, column)+"";
    
                JOptionPane.showMessageDialog(null, s);
    
    
    } 
    

    if you want click cell or row in jtable use this way

提交回复
热议问题