List of usage examples for com.intellij.openapi.ui.popup Balloon showInCenterOf
void showInCenterOf(JComponent component);
From source file:com.intellij.xdebugger.impl.ui.DebuggerUIUtil.java
License:Apache License
public static Balloon showBreakpointEditor(Project project, final JComponent mainPanel, final Point whereToShow, final JComponent component, @Nullable final Runnable showMoreOptions, Object breakpoint) { final BreakpointEditor editor = new BreakpointEditor(); editor.setPropertiesPanel(mainPanel); editor.setShowMoreOptionsLink(true); final JPanel panel = editor.getMainPanel(); final Balloon balloon = JBPopupFactory.getInstance().createDialogBalloonBuilder(panel, null) .setHideOnClickOutside(true).setCloseButtonEnabled(false).setAnimationCycle(0) .setBlockClicksThroughBalloon(true).createBalloon(); editor.setDelegate(new BreakpointEditor.Delegate() { @Override//from ww w . ja v a2 s.com public void done() { balloon.hide(); } @Override public void more() { assert showMoreOptions != null; balloon.hide(); showMoreOptions.run(); } }); if (whereToShow == null) { balloon.showInCenterOf(component); } else { //todo[kb] modify and move to BalloonImpl? final Window window = SwingUtilities.windowForComponent(component); final RelativePoint p = new RelativePoint(component, whereToShow); if (window != null) { final RelativePoint point = new RelativePoint(window, new Point(0, 0)); if (p.getScreenPoint().getX() - point.getScreenPoint().getX() < 40) { // triangle + offsets is ~40px p.getPoint().x += 40; } } balloon.show(p, Balloon.Position.below); } BreakpointsDialogFactory.getInstance(project).setBalloonToHide(balloon, breakpoint); return balloon; }