void (@NotNull JBPopup popup, @NotNull Presentation presentation) { popup.addListener(new JBPopupListener() { @Override public void beforeShown(@NotNull LightweightWindowEvent event) { Toggleable.setSelected(presentation, true); } @Override public void onClosed(@NotNull LightweightWindowEvent event) { Toggleable.setSelected(presentation, false); } }); }