javax.swing.JComponent#getLocationOnScreen ( )源码实例Demo

下面列出了javax.swing.JComponent#getLocationOnScreen ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ghidra   文件: DockingWindowManagerTest.java
private void assertAbove(DockingWindowManager dwm, ComponentProvider p1, ComponentProvider p2) {
	ComponentPlaceholder ph1 = dwm.getActivePlaceholder(p1);
	ComponentPlaceholder ph2 = dwm.getActivePlaceholder(p2);

	ComponentNode n1 = ph1.getNode();
	ComponentNode n2 = ph2.getNode();

	JComponent c1 = n1.getComponent();
	JComponent c2 = n2.getComponent();

	Point l1 = c1.getLocationOnScreen();
	Point l2 = c2.getLocationOnScreen();
	assertTrue(
		"Provider is not above the other provider.  " + p1.getName() + " / " + p2.getName(),
		l1.y < l2.y);
}
 
源代码2 项目: ghidra   文件: DockingWindowManagerTest.java
private void assertTotheRight(DockingWindowManager dwm, ComponentProvider p1,
		ComponentProvider p2) {
	ComponentPlaceholder ph1 = dwm.getActivePlaceholder(p1);
	ComponentPlaceholder ph2 = dwm.getActivePlaceholder(p2);

	ComponentNode n1 = ph1.getNode();
	ComponentNode n2 = ph2.getNode();

	JComponent c1 = n1.getComponent();
	JComponent c2 = n2.getComponent();

	Point l1 = c1.getLocationOnScreen();
	Point l2 = c2.getLocationOnScreen();
	assertTrue("Provider is not to the right of the other provider.  " + p1.getName() + " / " +
		p2.getName(), l1.x > l2.x);
}
 
源代码3 项目: ghidra   文件: DockingWindowManagerTest.java
private void assertStacked(DockingWindowManager dwm, ComponentProvider... providers) {

		Integer x = null;
		Integer y = null;

		for (ComponentProvider p : providers) {

			ComponentPlaceholder ph = dwm.getActivePlaceholder(p);
			ComponentNode n = ph.getNode();
			JComponent c = n.getComponent();
			Point l = c.getLocationOnScreen();

			if (x == null) {
				x = l.x;
				y = l.y;
			}
			else {
				assertEquals("Providers are not stacked together", x.intValue(), l.x);
				assertEquals("Providers are not stacked together", y.intValue(), l.y);
			}

		}
	}
 
源代码4 项目: pumpernickel   文件: BasicPopoverVisibility.java
/**
 * Return true if the mouse is currently over the argument.
 */
protected boolean isRollover(JComponent jc) {
	if (!jc.isShowing())
		return false;
	Point p = jc.getLocationOnScreen();
	int w = jc.getWidth();
	int h = jc.getHeight();

	Point mouse = MouseInfo.getPointerInfo().getLocation();

	return mouse.x >= p.x && mouse.y >= p.y && mouse.x < p.x + w
			&& mouse.y < p.y + h;
}
 
源代码5 项目: LGoodDatePicker   文件: DatePicker.java
/**
 * zSetPopupLocation, This calculates and sets the appropriate location for the popup windows,
 * for both the DatePicker and the TimePicker.
 */
static void zSetPopupLocation(CustomPopup popup, int defaultX, int defaultY, JComponent picker,
        JComponent verticalFlipReference, int verticalFlipDistance, int bottomOverlapAllowed) {
    // Gather some variables that we will need.
    Window topWindowOrNull = SwingUtilities.getWindowAncestor(picker);
    Rectangle workingArea = InternalUtilities.getScreenWorkingArea(topWindowOrNull);
    int popupWidth = popup.getBounds().width;
    int popupHeight = popup.getBounds().height;
    // Calculate the default rectangle for the popup.
    Rectangle popupRectangle = new Rectangle(defaultX, defaultY, popupWidth, popupHeight);
    // If the popup rectangle is below the bottom of the working area, then move it upwards by 
    // the minimum amount which will ensure that it will never cover the picker component.
    if (popupRectangle.getMaxY() > (workingArea.getMaxY() + bottomOverlapAllowed)) {
        popupRectangle.y = verticalFlipReference.getLocationOnScreen().y - popupHeight
                - verticalFlipDistance;
    }
    // Confine the popup to be within the working area.
    if (popupRectangle.getMaxX() > (workingArea.getMaxX())) {
        popupRectangle.x -= (popupRectangle.getMaxX() - workingArea.getMaxX());
    }
    if (popupRectangle.getMaxY() > (workingArea.getMaxY() + bottomOverlapAllowed)) {
        popupRectangle.y -= (popupRectangle.getMaxY() - workingArea.getMaxY());
    }
    if (popupRectangle.x < workingArea.x) {
        popupRectangle.x += (workingArea.x - popupRectangle.x);
    }
    if (popupRectangle.y < workingArea.y) {
        popupRectangle.y += (workingArea.y - popupRectangle.y);
    }
    // Set the location of the popup.
    popup.setLocation(popupRectangle.x, popupRectangle.y);
}
 
源代码6 项目: filthy-rich-clients   文件: Validator.java
private void repaintBadge(JComponent field) {
    Point p = field.getLocationOnScreen();
    SwingUtilities.convertPointFromScreen(p, this);
    
    int x = p.x - warningIcon.getWidth() / 2;
    int y = (int) (p.y + field.getHeight() - warningIcon.getHeight() / 1.5);
    
    repaint(x, y, warningIcon.getWidth(), warningIcon.getHeight());
}
 
源代码7 项目: jclic   文件: AbstractBox.java
public Point2D getAbsoluteLocation() {
  Point2D result = null;
  JComponent jc = getContainerResolve();
  if (jc != null) {
    result = new java.awt.Point(jc.getLocationOnScreen());
    result.setLocation(result.getX() + getX(), result.getY() + getY());
  }
  return result;
}
 
源代码8 项目: amodeus   文件: StandardMenu.java
public void atMouse(JComponent jComponent) {
    Point myMouse = DisplayHelper.getMouseLocation();
    Point myPoint = jComponent.getLocationOnScreen();
    designAndGetJPopupMenu().show(jComponent, myMouse.x - myPoint.x, myMouse.y - myPoint.y);
}