コード例 #1
0
ファイル: Util.java プロジェクト: opencadc/apps
 public static void setPositionRelativeToParent(
     Window w, Component parent, int hOffset, int vOffset) {
   try {
     Point p = parent.getLocationOnScreen();
     int x = (int) p.getX() + hOffset;
     int y = (int) p.getY() + vOffset;
     w.setLocation(x, y);
     w.pack();
   } catch (Throwable t) {
   }
 }
コード例 #2
0
ファイル: WizardPopup.java プロジェクト: ngoanhtan/consulo
    @Override
    public Dimension getPreferredSize() {
      final Component focusOwner =
          KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      Point p = null;
      if (focusOwner != null && focusOwner.isShowing()) {
        p = focusOwner.getLocationOnScreen();
      }

      return computeNotBiggerDimension(super.getPreferredSize().getSize(), p);
    }
コード例 #3
0
  public static Point getRelLocation(Component c) {
    if (c == null || !c.isShowing()) {
      return new Point(0, 0);
    }

    Container parent = getRootContainer(c);
    if ((parent != null) && parent.isShowing()) {
      Point p1 = c.getLocationOnScreen();
      Point p2 = parent.getLocationOnScreen();
      return new Point(p1.x - p2.x, p1.y - p2.y);
    }

    return new Point(0, 0);
  }
コード例 #4
0
  protected void customizePopup(BasicComboPopup popup) {
    scrollPane = getScrollPane(popup);

    if (popupWider) popupWider(popup);

    checkHorizontalScrollBar(popup);

    //  For some reason in JDK7 the popup will not display at its preferred
    //  width unless its location has been changed from its default
    //  (ie. for normal "pop down" shift the popup and reset)

    Component comboBox = popup.getInvoker();
    Point location = comboBox.getLocationOnScreen();

    if (popupAbove) {
      int height = popup.getPreferredSize().height;
      popup.setLocation(location.x, location.y - height);
    } else {
      int height = comboBox.getPreferredSize().height;
      popup.setLocation(location.x, location.y + height - 1);
      popup.setLocation(location.x, location.y + height);
    }
  }