void (@NotNull AnActionEvent e) { Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor == null) return; for (Balloon.Position position : Balloon.Position.values()) { JLabel popupContent = new JLabel("PositionTracker [" + position + "]", SwingConstants.CENTER); popupContent.setPreferredSize(new JBDimension(200, 50)); JBPopupFactory popupFactory = JBPopupFactory.getInstance(); popupFactory .createDialogBalloonBuilder(popupContent, null) .createBalloon() .show(new PositionTracker<>(editor.getContentComponent()) { @Override public RelativePoint recalculateLocation(@NotNull Balloon balloon) { return popupFactory.guessBestPopupLocation(editor); } }, position); } }