当前位置: 技术问答>java相关
如何捕捉JTable的鼠标事件?
来源: 互联网 发布时间:2015-08-08
本文导语: 如何捕捉JTable的鼠标双击事件,再获得所在行的行号.谢谢. | table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2) { int index = table.getSel...
如何捕捉JTable的鼠标双击事件,再获得所在行的行号.谢谢.
|
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(e.getClickCount() == 2) {
int index = table.getSelectedRow();
}
}
});
public void mouseClicked(MouseEvent e) {
if(e.getClickCount() == 2) {
int index = table.getSelectedRow();
}
}
});
|
filesTable.addMouseListener( new TableMouseAdapter());
public class TableMouseAdapter extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() >= 2) {
table.getSelectedRow()
}
}
}
public class TableMouseAdapter extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() >= 2) {
table.getSelectedRow()
}
}
}
|
int[] select_index = jTable_bill.getSelectedRows();
int count = jTable_bill.getSelectedRowCount();
int count = jTable_bill.getSelectedRowCount();