javax.swing.SwingUtilities#convertPointFromScreen ( )源码实例Demo

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

源代码1 项目: filthy-rich-clients   文件: PictureGlassPane.java
public void moveIt(Point location) {
    Point oldLocation = this.location;
    SwingUtilities.convertPointFromScreen(location, this);
    this.location = location;
    
    Rectangle newClip = new Rectangle(location.x - image.getWidth() / 2, location.y - image.getHeight() / 2,
            image.getWidth(), image.getHeight());
    newClip.add(new Rectangle(oldLocation.x - image.getWidth() / 2, oldLocation.y - image.getHeight() / 2,
            image.getWidth(), image.getHeight()));
    newClip.add(new Rectangle(oldLocation.x - image.getWidth() / 2, oldLocation.y - image.getHeight() / 2,
            shadow.getWidth(), shadow.getHeight()));
    newClip.add(new Rectangle(location.x - image.getWidth() / 2, location.y - image.getHeight() / 2,
            shadow.getWidth(), shadow.getHeight()));

    repaint(newClip);
}
 
源代码2 项目: pumpernickel   文件: CustomizedToolbar.java
protected void endDrag(DragSourceDropEvent e) {
	if (draggingComponent != null) {
		Point p = e.getLocation();
		SwingUtilities.convertPointFromScreen(p, this);
		if (contains(p) == false) {
			// adding this extra ability to commit changes
			// makes sure if you simply drag an element
			// off the toolbar: it gets recorded.
			setContents(getContents(new Point(-1000, -1000)));
		}
	}
	draggingComponent = null;
	/**
	 * TODO: is there some way when a drop ends if it IS accepted to NOT
	 * show the image slide back to its original location? For example: 1.
	 * Open this demo app 2. Click "Customize" 3. Drag a component off the
	 * toolbar in the window into nothingness. Note the *image* slides back
	 * to where it came from, because this is how the OS shows the drag was
	 * not accepted. But even though it was not accepted by any other
	 * entity: the drag was successful, and showing that sliding image is
	 * incorrect.
	 */
}
 
源代码3 项目: netbeans   文件: AnnotationBar.java
/**
 *
 * @param event
 */
private void showTooltipWindow (MouseEvent event) {
    Point p = new Point(event.getPoint());
    SwingUtilities.convertPointToScreen(p, this);
    Point p2 = new Point(p);
    SwingUtilities.convertPointFromScreen(p2, textComponent);
    
    // annotation for target line
    AnnotateLine al = null;
    if (!elementAnnotations.isEmpty()) {
        al = getAnnotateLine(getLineFromMouseEvent(event));
    }

    /**
     * al.getCommitMessage() != null - since commit messages are initialized separately from the AL constructor
     */
    if (al != null && al.getCommitMessage() != null) {
        TooltipWindow ttw = new TooltipWindow(this, al);
        ttw.show(new Point(p.x - p2.x, p.y));
    }
}
 
源代码4 项目: libreveris   文件: ScreenPoint.java
/**
 * Get the corresponding local point wrt a containing component
 *
 * @param component the provided component
 * @return the local point, wrt component top left corner
 */
public Point getLocalPoint (Component component)
{
    Point localPoint = new Point(x, y);
    SwingUtilities.convertPointFromScreen(localPoint, component);

    return localPoint;
}
 
源代码5 项目: jdk8u-jdk   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码6 项目: filthy-rich-clients   文件: PictureGlassPane.java
public void showIt(BufferedImage image, Point location) {
    this.image = image;
    this.shadow = new ShadowRenderer(5, 0.3f, Color.BLACK).createShadow(image);

    SwingUtilities.convertPointFromScreen(location, this);
    this.location = location;
    
    setVisible(true);
}
 
源代码7 项目: jdk8u60   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码8 项目: nanoleaf-desktop   文件: EffectOptionsMenu.java
private Point getMenuLocation()
{
	Point menuPoint = MouseInfo.getPointerInfo().getLocation();
	JScrollPane scrollPane = (JScrollPane)effectsPanel.getList().getParent().getParent();
	SwingUtilities.convertPointFromScreen(menuPoint, scrollPane);
	int listLocation = effectsPanel.getY();
	return new Point(menuPoint.x, menuPoint.y + listLocation);
}
 
源代码9 项目: openjdk-jdk8u   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码10 项目: netbeans   文件: SplitLayerUI.java
private void update( Point locationOnScreen ) {
    if( null != locationOnScreen ) {
        SwingUtilities.convertPointFromScreen( locationOnScreen, content );
        lastLocation = locationOnScreen;
        horizontalSplit = calculateOrientation();
        lastLocation.x = Math.max( 0, lastLocation.x );
        lastLocation.y = Math.max( 0, lastLocation.y );
        lastLocation.x = Math.min( content.getWidth()-splitterWidth, lastLocation.x );
        lastLocation.y = Math.min( content.getHeight()-splitterWidth, lastLocation.y );
        content.repaint();
    } else {
        lastLocation = null;
    }
}
 
源代码11 项目: 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());
}
 
源代码12 项目: netbeans   文件: MergeDialogComponent.java
/** Shows given popup on given coordinations and takes care about the
 *  situation when menu can exceed screen limits.
 *  Copied from org.netbeans.core.windows.frames.DefaultContainerImpl
 */
private static void showPopupMenu(JPopupMenu popup, Point p, Component comp) {
    SwingUtilities.convertPointToScreen(p, comp);
    Dimension popupSize = popup.getPreferredSize();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    
    if (p.x + popupSize.width > screenSize.width) {
        p.x = screenSize.width - popupSize.width;
    }
    if (p.y + popupSize.height > screenSize.height) {
        p.y = screenSize.height - popupSize.height;
    }
    SwingUtilities.convertPointFromScreen(p, comp);
    popup.show(comp, p.x, p.y);
}
 
源代码13 项目: binnavi   文件: GuiHelper.java
public static Component findComponentAt(final Container c, final Point sp) {
  final Point cp = new Point(sp.x, sp.y);
  SwingUtilities.convertPointFromScreen(cp, c);

  if (!c.contains(cp.x, cp.y)) {
    return c;
  }

  final int ncomponents = c.getComponentCount();
  final Component component[] = c.getComponents();
  for (int i = 0; i < ncomponents; i++) {
    final Component comp = component[i];
    final Point loc = comp.getLocation();
    if ((comp.contains(cp.x - loc.x, cp.y - loc.y)) && (comp.isVisible() == true)) {
      // found a component that intersects the point, see if there
      // is a deeper possibility.
      if (comp instanceof Container) {
        final Container child = (Container) comp;
        final Component deeper = findComponentAt(child, sp);
        if (deeper != null) {
          return deeper;
        }
      } else {
        return comp;
      }
    }
  }

  return c;
}
 
源代码14 项目: pumpernickel   文件: MagnificationPanel.java
protected Point getMouseLoc() {
	// I observed a null PointerInfo after unplugging a second monitor
	PointerInfo pointerInfo = MouseInfo.getPointerInfo();
	if (pointerInfo == null)
		return null;
	Point p = pointerInfo.getLocation();
	SwingUtilities.convertPointFromScreen(p, zoomedComponent);
	return p;
}
 
源代码15 项目: WorldGrower   文件: GuiMouseListener.java
@Override
public void actionPerformed(ActionEvent actionEvent) {
	Point location = MouseInfo.getPointerInfo().getLocation();
	SwingUtilities.convertPointFromScreen(location, container);
	showBuildingsAction(location.x, location.y);
}
 
源代码16 项目: netbeans   文件: ListView.java
void createPopup(int xpos, int ypos, boolean contextMenu) {
    if (manager == null) {
        return;
    }

    if (!popupAllowed) {
        return;
    }
    
    if (!isShowing()) {
        return;
    }

    JPopupMenu popup;

    if (contextMenu) {
        popup = Utilities.actionsToPopup(manager.getExploredContext().getActions(true), this);
    } else {
        Action[] actions = NodeOp.findActions(manager.getSelectedNodes());
        popup = Utilities.actionsToPopup(actions, this);
    }

    if ((popup != null) && (popup.getSubElements().length > 0)) {
        Point p = getViewport().getViewPosition();
        p.x = xpos - p.x;
        p.y = ypos - p.y;

        SwingUtilities.convertPointToScreen(p, ListView.this);

        Dimension popupSize = popup.getPreferredSize();
        Rectangle screenBounds = Utilities.getUsableScreenBounds(getGraphicsConfiguration());

        if ((p.x + popupSize.width) > (screenBounds.x + screenBounds.width)) {
            p.x = (screenBounds.x + screenBounds.width) - popupSize.width;
        }

        if ((p.y + popupSize.height) > (screenBounds.y + screenBounds.height)) {
            p.y = (screenBounds.y + screenBounds.height) - popupSize.height;
        }

        SwingUtilities.convertPointFromScreen(p, ListView.this);
        popup.show(this, p.x, p.y);
    }
}
 
源代码17 项目: WorldGrower   文件: GuiMouseListener.java
@Override
public void actionPerformed(ActionEvent actionEvent) {
	Point location = MouseInfo.getPointerInfo().getLocation();
	SwingUtilities.convertPointFromScreen(location, container);
	showProductionBuildingsAction(location.x, location.y);
}
 
源代码18 项目: triplea   文件: MapUnitTooltipManager.java
private boolean isPointWithinParentBounds(final Point pointInScreenCoordinates) {
  final Point pointInParentCoordinates = new Point(pointInScreenCoordinates);
  SwingUtilities.convertPointFromScreen(pointInParentCoordinates, parent);
  return parent.getBounds().contains(pointInParentCoordinates);
}
 
源代码19 项目: WorldGrower   文件: GuiMouseListener.java
@Override
public void actionPerformed(ActionEvent actionEvent) {
	Point location = MouseInfo.getPointerInfo().getLocation();
	SwingUtilities.convertPointFromScreen(location, container);
	showPlayerCharacterMenu(location.x, location.y);
}
 
源代码20 项目: WorldGrower   文件: GuiMouseListener.java
@Override
public void actionPerformed(ActionEvent actionEvent) {
	Point location = MouseInfo.getPointerInfo().getLocation();
	SwingUtilities.convertPointFromScreen(location, container);
	showPlantAction(location.x, location.y);
}