I have been working on how to enable the right click and show a popup menu it was asked earlier at Enable right click in jFrame but it was not as useful actually my problem is that I am facing the left click as enable also my piece of code that I have been using is:
private void jTextField1MousePressed(java.awt.event.MouseEvent evt){
if (!evt.isPopupTrigger()){
p.show(evt.getComponent(), evt.getX(), evt.getY());
}
}
The problem is that the left mouse click is also popping up a menu. What I want is to just pop up the menu on the right click. Please suggest me a solution and the blunder I'm doing here Thanks in advance
I think this code snippet will help you:
if (evt.getModifiers() == MouseEvent.BUTTON3_MASK){
//right click
}
For further information see the JDoc of MouseEvent
.