JBPopup (Project project, Consumer<String> inputCallback) { EmojiPicker picker = new EmojiPicker(); JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(picker, picker.mySearchField) .setProject(project) .setModalContext(false) .setCancelOnClickOutside(true) .setRequestFocus(true) .setCancelKeyEnabled(false) .setResizable(false) .setMovable(true) .setLocateWithinScreenBounds(true) .setMinSize(DEFAULT_SIZE.size()) .setShowBorder(false) .createPopup(); picker.myInputCallback = emoji -> { if (emoji != null) { inputCallback.accept(emoji); popup.closeOk(null); } else { popup.cancel(); } }; return popup; }