My jPopupMenu object jPopupMenu on a specific event when the user right- JTable table ( JTable ). It is necessary to hide it if the user clicks outside the zone of the menu and the table itself with any button or show it in another place if the user clicks with the right button.

Well, to show in another place turned out, just changing the location. And if it is already open, I can hide it, provided that I clicked on the table. How to hide if the user clicks on the application window?

  • Understood, now I will write the answer. - Jakeroid pm

1 answer 1

You need the application window to inherit the WindowAdapter class, the method you need:

 public void windowActivated(WindowEvent e) { ... } 

handles events when the window is activated; there you can write something like popupMenu.setVisible(false); or whatever your code is.

  • Thank you, I also thought of this. - Jakeroid