public MyEditor(final JComboBox comboBox, final ComboBoxEditor delegate) {
   myComboBox = comboBox;
   myDelegate = delegate;
   if (myDelegate != null) {
     myDelegate.addActionListener(
         new ActionListener() {
           public void actionPerformed(final ActionEvent e) {
             if (myComboBox.isPopupVisible()) {
               myComboBox.setPopupVisible(false);
             } else {
               final Object clientProperty =
                   myComboBox.getClientProperty(TABLE_CELL_EDITOR_PROPERTY);
               if (clientProperty instanceof CellEditor) {
                 // If combo box is inside editable table then we need to cancel editing
                 // and do not close heavy weight dialog container (if any)
                 ((CellEditor) clientProperty).stopCellEditing();
               } else {
                 myComboBox.setSelectedItem(getItem());
                 final JRootPane rootPane = myComboBox.getRootPane();
                 if (rootPane != null) {
                   final JButton button = rootPane.getDefaultButton();
                   if (button != null) {
                     button.doClick();
                   }
                 }
               }
             }
           }
         });
   }
 }