private void initComboBox(JComboBox combo) {
   if (combo.getUI() instanceof WindowsComboBoxUI) {
     combo.setUI(new RightPopupWindowsComboBoxUI());
   } else {
     combo.setUI(new RightPopupBasicComboBoxUI());
   }
   combo.addPopupMenuListener(new RightPopupMenuListener());
 }
    public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
      Point cpos = combo1.getLocation();
      SwingUtilities.convertPointToScreen(cpos, panel);

      JPopupMenu pm = (JPopupMenu) combo1.getUI().getAccessibleChild(combo1, 0);

      if (pm != null) {
        Point p = pm.getLocation();
        SwingUtilities.convertPointToScreen(p, pm);
        if (p.y < cpos.y) {
          throw new RuntimeException("ComboBox popup is wrongly aligned");
        } // check that popup was opened down
      }
    }