The solution was found, creating a routine which is instantiated as soon as the JPopupMenu becomes visible, this will be constantly checking that the position of the mouse is not greater than the JPopupMenu position + the size, the routine is destroyed just the JPopupMenu disappears. I share the code in case someone may need it.
Point coordenadasMouseNow = MouseInfo.getPointerInfo().getLocation();
Point coordenadasJTable = jTable1.getLocationOnScreen();
if(coordenadasMouseNow.x > coordenadasJTable.x+jTable1.getWidth() ||
coordenadasMouseNow.x < coordenadasJTable.x ||
coordenadasMouseNow.y > coordenadasJTable.y+jTable1.getHeight() ||
coordenadasMouseNow.y < coordenadasJTable.y){
jPopupMenu1.setVisible(false);
return;
}
rutina = new Timer(60, (ActionEvent e) -> {
Point coordenadasMouse = MouseInfo.getPointerInfo().getLocation();
Point coordenadasJPopupMenu = jPopupMenu1.getLocationOnScreen();
if(coordenadasMouse.x > coordenadasJPopupMenu.x+jPopupMenu1.getWidth() ||
coordenadasMouse.x < coordenadasJPopupMenu.x ||
coordenadasMouse.y > coordenadasJPopupMenu.y+jPopupMenu1.getHeight() ||
coordenadasMouse.y < coordenadasJPopupMenu.y){
jPopupMenu1.setVisible(false);
}
});
rutina.start();