// Event forwarding. We need it if user does press-and-drag gesture for opening popup and
 // choosing item there.
 // It works in JComboBox, here we provide the same behavior
 private void dispatchEventToPopup(MouseEvent e) {
   if (myPopup != null && myPopup.isVisible()) {
     JComponent content = myPopup.getContent();
     Rectangle rectangle = content.getBounds();
     Point location = rectangle.getLocation();
     SwingUtilities.convertPointToScreen(location, content);
     Point eventPoint = e.getLocationOnScreen();
     rectangle.setLocation(location);
     if (rectangle.contains(eventPoint)) {
       MouseEvent event =
           SwingUtilities.convertMouseEvent(e.getComponent(), e, myPopup.getContent());
       Component component =
           SwingUtilities.getDeepestComponentAt(content, event.getX(), event.getY());
       if (component != null) component.dispatchEvent(event);
     }
   }
 }