void (@NotNull AnActionEvent e) { final JPanel result = new JPanel(new BorderLayout()); final JLabel label = new JLabel(myConfiguration.getSelectText()); label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0)); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(label, BorderLayout.NORTH); final Map<Integer, JLabel> map = myConfiguration.getDictionary(); final JSlider slider = new JSlider(SwingConstants.HORIZONTAL, myConfiguration.getMin(), myConfiguration.getMax(), myConfiguration.getSelected()) { Integer myWidth = null; @Override public Dimension getPreferredSize() { final Dimension size = super.getPreferredSize(); if (myWidth == null) { myWidth = 10; final FontMetrics fm = getFontMetrics(getFont()); for (JLabel confLabel : map.values()) { String text = confLabel.getText(); myWidth += fm.stringWidth(text + "W"); } } return new Dimension(myWidth, size.height); } }; slider.setMinorTickSpacing(1); slider.setPaintTicks(true); slider.setPaintTrack(true); slider.setSnapToTicks(true); UIUtil.setSliderIsFilled(slider, true); slider.setPaintLabels(true); //noinspection UseOfObsoleteCollectionType slider.setLabelTable(new Hashtable<>(map)); result.add(wrapper, BorderLayout.WEST); result.add(slider, BorderLayout.CENTER); final Runnable saveSelection = () -> { int value = slider.getModel().getValue(); myConfiguration.getResultConsumer().consume(value); }; final Ref<JBPopup> popupRef = new Ref<>(null); final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider) .setMovable(true) .setCancelOnWindowDeactivation(true) .setCancelKeyEnabled(myConfiguration.isShowOk()) .setKeyboardActions(Collections.singletonList(Pair.create(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveSelection.run(); popupRef.get().closeOk(null); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)))) .createPopup(); popupRef.set(popup); if (myConfiguration.isShowOk()) { final JButton done = new JButton(IdeBundle.message("button.done")); final JBPanel doneWrapper = new JBPanel(new BorderLayout()); doneWrapper.add(done, BorderLayout.NORTH); result.add(doneWrapper, BorderLayout.EAST); done.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveSelection.run(); popup.closeOk(null); } }); } else { popup.setFinalRunnable(saveSelection); } InputEvent inputEvent = e.getInputEvent(); show(e, result, popup, inputEvent); }