I observed one thing about my right click on the JTable.
If I right click on a row. it shows my popUpMenu item.
But now if I right click on another row, I must
right click 2 times on the other row before my Jpopup appears.
Is that any way to make it smoother as in I only need to right click one time on
another row?
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
System.out.println("Right Click");
int r = table.rowAtPoint(e.getPoint());
if (r >= 0 && r < table.getRowCount()) {
table.setRowSelectionInterval(r, r);
} else {
table.clearSelection();
}
int rowindex = table.getSelectedRow();
if (rowindex < 0)
return;
if (e.isPopupTrigger() && e.getComponent() instanceof JTable ) {
item = popupMenu.add("itemOne");
table.setComponentPopupMenu(popupMenu);
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
}
});