Alb*_*sut 0 java swing jtable jpopupmenu
从附图中我有一个jTable 
右键单击一行会启动一个jPopup,其中包含一个"Thread Stop"项.
我想通过单击此菜单项返回行号
怎么做到这一点?
谢谢.
在显示弹出窗口的MouseListener中,只需通过JTable方法获取行号和列号:
table.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int col = table.columnAtPoint(p);
System.out.printf("row, col: [%d, %d]%n", row, col);
// show pop-up menu here
}
});
Run Code Online (Sandbox Code Playgroud)