Java Code Examples for javax.swing.SwingUtilities#convertPointFromScreen()
The following examples show how to use
javax.swing.SwingUtilities#convertPointFromScreen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PictureGlassPane.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); }
Example 2
Source File: AnnotationBar.java From netbeans with Apache License 2.0 | 6 votes |
/** * * @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)); } }
Example 3
Source File: CustomizedToolbar.java From pumpernickel with MIT License | 6 votes |
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. */ }
Example 4
Source File: SplitLayerUI.java From netbeans with Apache License 2.0 | 5 votes |
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; } }
Example 5
Source File: GuiHelper.java From binnavi with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: MagnificationPanel.java From pumpernickel with MIT License | 5 votes |
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; }
Example 7
Source File: MergeDialogComponent.java From netbeans with Apache License 2.0 | 5 votes |
/** 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); }
Example 8
Source File: Validator.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()); }
Example 9
Source File: ScreenPoint.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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; }
Example 10
Source File: ListView.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 11
Source File: JLightweightFrame.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 12
Source File: EffectOptionsMenu.java From nanoleaf-desktop with MIT License | 5 votes |
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); }
Example 13
Source File: JLightweightFrame.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 14
Source File: PictureGlassPane.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); }
Example 15
Source File: JLightweightFrame.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 16
Source File: GuiMouseListener.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed(ActionEvent actionEvent) { Point location = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(location, container); showProductionBuildingsAction(location.x, location.y); }
Example 17
Source File: GuiMouseListener.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed(ActionEvent actionEvent) { Point location = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(location, container); showPlantAction(location.x, location.y); }
Example 18
Source File: GuiMouseListener.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed(ActionEvent actionEvent) { Point location = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(location, container); showPlayerCharacterMenu(location.x, location.y); }
Example 19
Source File: MapUnitTooltipManager.java From triplea with GNU General Public License v3.0 | 4 votes |
private boolean isPointWithinParentBounds(final Point pointInScreenCoordinates) { final Point pointInParentCoordinates = new Point(pointInScreenCoordinates); SwingUtilities.convertPointFromScreen(pointInParentCoordinates, parent); return parent.getBounds().contains(pointInParentCoordinates); }
Example 20
Source File: GuiMouseListener.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed(ActionEvent actionEvent) { Point location = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(location, container); showBuildingsAction(location.x, location.y); }