void () { myJustClosedViaClick = false; if (myPopup != null) { if (myPopup.isVisible()) return; // onClosed() was not called for some reason myPopup.cancel(); } //noinspection unchecked T selectedItem = (T)myComboBox.getSelectedItem(); myPopup = createPopup(selectedItem); if (ScreenReader.isActive()) { myPopup.setRequestFocus(true); } myPopup.addListener(new JBPopupListener() { @Override public void beforeShown(@NotNull LightweightWindowEvent event) { myComboBox.firePopupMenuWillBecomeVisible(); //model may drift from the time we decided to open the popup, //let's update it to make sure we did not miss anything if (useLiveUpdateWithModel()) { myPopup.syncWithModelChange(); } } @Override public void onClosed(@NotNull LightweightWindowEvent event) { myComboBox.firePopupMenuWillBecomeInvisible(); myPopup = null; } }); myPopup.addListener((AccessibleDarculaJBPopupComboPopup)getAccessibleContext()); myPopup.setMinimumSize(myComboBox.getSize()); myPopup.showUnderneathOf(myComboBox); }