private void addContextMenuMouseListener(final JComponent c) {
c.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
ContextMenu menu = new ContextMenu(c);
menu.show(e.getX(), e.getY());
}
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
ContextMenu menu = new ContextMenu(c);
menu.show(e.getX(), e.getY());
}
}
});
}