如何监听JTable
表格标题上的鼠标点击?
如果我喜欢这个
getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
//fireOpenActionPerformed();
openActionCascade.actionPerformed(null);
}
}
});
我不知道在处理程序中单击了哪一列。
最佳答案
"the I can't know which column was clicked when in handler."
怎么样JTableHeader#columnAtPoint(Point point)
? (即 MouseEvent.getPoint)
Returns the index of the column that point lies in, or -1 if it lies out of bounds
关于java - 如何监听JTable表头的鼠标点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26740604/