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

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

源代码1 项目: netbeans   文件: SlideGestureRecognizer.java
/** @return true when conditions for auto slide OUT were met, false otherwise */
private boolean isSlideOutGesture(MouseEvent evt) {
    if (resizer.isDragging()) {
        activeArea = null;
        return false;
    }
    if (activeArea == null) {
        activeArea = computeActiveArea();
        // comps are not yet ready, so do nothing
        if (activeArea == null) {
            return false;
        }
    }
    Point mouseLoc = evt.getPoint();
    //#118828
    if (! (evt.getSource() instanceof Component)) {
        return false;
    }
    
    SwingUtilities.convertPointToScreen(mouseLoc, (Component)evt.getSource());
    
    boolean isMouseOut = !activeArea.contains(mouseLoc);
    
    return isMouseOut;
}
 
源代码2 项目: netbeans   文件: Central.java
@Override
public void userUndockedTopComponent(TopComponent tc, ModeImpl mode) {
    Point tcLoc = tc.getLocation();
    Dimension tcSize = tc.getSize();
    SwingUtilities.convertPointToScreen(tcLoc, tc);
    Rectangle bounds = new Rectangle(tcLoc, tcSize);
    // #89100: update mode kind when undocking view in sliding mode
    int modeKind = mode.getKind();
    if (modeKind == Constants.MODE_KIND_SLIDING) {
        modeKind = Constants.MODE_KIND_VIEW;
    }
    // #81479: unmaximize only if desirable
    if (getCurrentMaximizedMode() == mode &&
        mode.getOpenedTopComponents().size() == 1 &&
        mode.getOpenedTopComponents().get(0) == tc) {
        switchMaximizedMode(null);
    }
    ModeImpl newMode = createFloatingMode( bounds, modeKind );
    moveTopComponentIntoMode( newMode, tc );
    updateViewAfterDnD(false);
    WindowManagerImpl.getInstance().doFirePropertyChange(
        WindowManager.PROP_MODES, null, null);
}
 
源代码3 项目: netbeans   文件: KeymapPanel.java
/**
     * Shows popup with ESC and TAB keys
     */
    private void moreButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moreButtonActionPerformed
        if (searchPopup != null) {
            return;
        }
        JComponent tf = (JComponent) evt.getSource();
        Point p = new Point(tf.getX(), tf.getY());
        SwingUtilities.convertPointToScreen(p, this);
        Rectangle usableScreenBounds = Utilities.getUsableScreenBounds();
        if (p.x + specialkeyList.getWidth() > usableScreenBounds.width) {
            p.x = usableScreenBounds.width - specialkeyList.getWidth();
        }
        if (p.y + specialkeyList.getHeight() > usableScreenBounds.height) {
            p.y = usableScreenBounds.height - specialkeyList.getHeight();
        }
        //show special key popup
        searchPopup = PopupFactory.getSharedInstance().getPopup(this, specialkeyList, p.x, p.y);
        searchPopup.show();
}
 
源代码4 项目: netbeans   文件: ListCompletionView.java
public boolean right() {
        Fix f = (Fix) getSelectedValue();
        Iterable<? extends Fix> subfixes = HintsControllerImpl.getSubfixes(f);

        if (subfixes.iterator().hasNext()) {
            Rectangle r = getCellBounds(getSelectedIndex(), getSelectedIndex());
            Point p = new Point(r.getLocation());
            SwingUtilities.convertPointToScreen(p, this);
            p.x += r.width;
//            p.y += r.height;
            HintsUI.getDefault().openSubList(subfixes, p);
            return true;
        }

        return false;
    }
 
源代码5 项目: jdk8u_jdk   文件: bug6495920.java
public void firstShowPopup() throws Exception {
    Point point = this.panel.getLocation();
    SwingUtilities.convertPointToScreen(point, this.panel);

    robot = new Robot(); // initialize shared static field first time
    robot.mouseMove(point.x + 1, point.y + 1);
    robot.mousePress(InputEvent.BUTTON3_MASK);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    robot.mouseRelease(InputEvent.BUTTON3_MASK); // causes first AssertionError on EDT
}
 
源代码6 项目: visualvm   文件: ProfilerPopup.java
private static ProfilerPopup create(Component invoker, Component content, int x, int y, int popupAlign, int resizeMode, Listener listener) {
    Point location = new Point(x, y);
    Dimension size = new Dimension();
    Window owner = null;
    
    if (invoker != null) {
        SwingUtilities.convertPointToScreen(location, invoker);
        size.setSize(invoker.getSize());
        owner = SwingUtilities.getWindowAncestor(invoker);
    }
    
    return new ProfilerPopup(content, new Rectangle(location, size), popupAlign, owner, resizeMode, listener);
}
 
源代码7 项目: pumpernickel   文件: ListCellPopupTarget.java
@Override
public Rectangle getScreenBounds() {
	if (!list.isShowing())
		return null;

	Rectangle r = list.getUI().getCellBounds(list, selectedIndex,
			selectedIndex);
	Point p = new Point(0, 0);
	SwingUtilities.convertPointToScreen(p, list);
	r.x += p.x;
	r.y += p.y;

	int insetX = 0;
	if (r.width > 30) {
		insetX = 10;
	} else if (r.width > 15) {
		insetX = 4;
	} else if (r.width > 8) {
		insetX = 1;
	}
	r.x += insetX;
	r.width -= 2 * insetX;

	int insetY = 0;
	if (r.height > 30) {
		insetY = 10;
	} else if (r.height > 15) {
		insetY = 4;
	} else if (r.height > 8) {
		insetY = 1;
	}
	r.y += insetY;
	r.height -= 2 * insetY;

	return r;
}
 
源代码8 项目: openjdk-jdk8u   文件: Test7163696.java
private void test() throws Exception {
    Robot robot = new Robot();
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(info.getClassName());

        SwingUtilities.invokeAndWait(this);
        toolkit.realSync(); // after creation
        Thread.sleep(1000);

        Point point = this.bar.getLocation();
        SwingUtilities.convertPointToScreen(point, this.bar);
        point.x += this.bar.getWidth() >> 2;
        point.y += this.bar.getHeight() >> 1;
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        toolkit.realSync(); // before validation
        Thread.sleep(1000);
        SwingUtilities.invokeAndWait(this);

        if (this.bar != null) {
            this.bar = null; // allows to reuse the instance
            if (AUTO) { // error reporting only for automatic testing
                throw new Error("TEST FAILED");
            }
        }
    }
}
 
源代码9 项目: jdk8u-dev-jdk   文件: bug6495920.java
public void secondHidePopup() {
    Point point = this.panel.getLocation();
    SwingUtilities.convertPointToScreen(point, this.panel);

    robot.mouseMove(point.x - 1, point.y - 1);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    robot.mousePress(InputEvent.BUTTON1_MASK); // causes second AssertionError on EDT
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
 
源代码10 项目: jdk8u-jdk   文件: bug6495920.java
public void secondHidePopup() {
    Point point = this.panel.getLocation();
    SwingUtilities.convertPointToScreen(point, this.panel);

    robot.mouseMove(point.x - 1, point.y - 1);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    robot.mousePress(InputEvent.BUTTON1_MASK); // causes second AssertionError on EDT
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
 
源代码11 项目: netbeans   文件: InnerPanelSupport.java
@Override
public void mouseMoved(MouseEvent e) {
    Point p = e.getPoint();
    int col = listClasses.columnAtPoint(p);
    int row = listClasses.rowAtPoint(p);
    
    if (col < 0 || row < 0) {
        hidePopup();
        return;
    }
    if (col == currentCol && row == currentRow) {
        // the tooltip is (probably) shown, do not create again
        return;
    }
    Rectangle cellRect = listClasses.getCellRect(row, col, false);
    Point pt = cellRect.getLocation();
    SwingUtilities.convertPointToScreen(pt, listClasses);
    
    RenderedImage ri = new RenderedImage();
    if (!updateTooltipImage(ri, row, col)) {
        return;
    }
    ri.addMouseListener(this);
    
    Popup popup = PopupFactory.getSharedInstance().getPopup(listClasses, ri, pt.x, pt.y);
    popupContents = ri;
    currentPopup = popup;
    currentCol = col;
    currentRow = row;
    popup.show();
    System.err.println("Hello");
}
 
源代码12 项目: TencentKona-8   文件: bug6495920.java
public void firstShowPopup() throws Exception {
    Point point = this.panel.getLocation();
    SwingUtilities.convertPointToScreen(point, this.panel);

    robot = new Robot(); // initialize shared static field first time
    robot.mouseMove(point.x + 1, point.y + 1);
    robot.mousePress(InputEvent.BUTTON3_MASK);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    robot.mouseRelease(InputEvent.BUTTON3_MASK); // causes first AssertionError on EDT
}
 
源代码13 项目: filthy-rich-clients   文件: VistaSearchDialog.java
@Override
public void mouseDragged(MouseEvent e) {
    Point point = e.getPoint();
    SwingUtilities.convertPointToScreen(point, (Component) e.getSource());
    int distance_x = point.x - startPoint.x;
    int distance_y = point.y - startPoint.y;

    VistaSearchDialog.this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));

    Point location = VistaSearchDialog.this.getLocation();
    Point oldLocation = (Point) location.clone();
    location.x += distance_x;
    location.y += distance_y;

    VistaSearchDialog.this.setLocation(location);

    Rectangle clip = new Rectangle(oldLocation.x, oldLocation.y,
                                   VistaSearchDialog.this.getWidth(),
                                   VistaSearchDialog.this.getHeight());
    clip.intersects(new Rectangle(location.x, location.y,
                                  VistaSearchDialog.this.getWidth(),
                                  VistaSearchDialog.this.getHeight()));

    VistaSearchDialog.this.getParent().repaint(clip.x, clip.y,
                                               clip.width, clip.height);

    startPoint = point;
}
 
源代码14 项目: jdk8u_jdk   文件: Test6505027.java
public void press() throws AWTException {
    Point point = this.table.getCellRect(1, 1, false).getLocation();
    SwingUtilities.convertPointToScreen(point, this.table);

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    robot.mouseMove(point.x + 1, point.y + 1);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
 
源代码15 项目: netbeans   文件: IsOverriddenAnnotationAction.java
static void mouseClicked(Map<String, List<ElementDescription>> caption2Descriptions, JTextComponent c, Point p) {
    if (caption2Descriptions.size() == 1 && caption2Descriptions.values().iterator().next().size() == 1) {
        ElementDescription desc = caption2Descriptions.values().iterator().next().get(0);
        desc.open();

        return ;
    }
    
    Point position = new Point(p);

    SwingUtilities.convertPointToScreen(position, c);

    StringBuilder caption = new StringBuilder();
    List<ElementDescription> descriptions = new LinkedList<ElementDescription>();
    boolean first = true;

    for (Entry<String, List<ElementDescription>> e : caption2Descriptions.entrySet()) {
        if (!first) {
            caption.append("/");
        }
        first = false;
        caption.append(e.getKey());
        descriptions.addAll(e.getValue());
    }

    PopupUtil.showPopup(new IsOverriddenPopup(caption.toString(), descriptions), caption.toString(), position.x, position.y, true, 0);
}
 
源代码16 项目: TencentKona-8   文件: JRobot.java
/**
 * Convert a rectangle from coordinate system of Component c to
 * screen coordinate system.
 * @param r a non-null Rectangle
 * @param c a Component whose coordinate system is used for conversion
 */
public void convertRectToScreen(Rectangle r, Component c) {
    Point p = new Point(r.x, r.y);
    SwingUtilities.convertPointToScreen(p, c);
    r.x = p.x;
    r.y = p.y;
}
 
源代码17 项目: netbeans   文件: IsOverriddenAnnotationAction.java
private static void mouseClicked(Map<String, List<OverrideDescription>> caption2Descriptions, JTextComponent c, Point p) {
    if (caption2Descriptions.size() == 1 && caption2Descriptions.values().iterator().next().size() == 1) {
        OverrideDescription desc = caption2Descriptions.values().iterator().next().get(0);
        FileObject file = desc.location.getLocation().getFileObject();

        if (file != null) {
            UiUtils.open(file, desc.location.getLocation().getOffset());
        } else {
            Toolkit.getDefaultToolkit().beep();
        }

        return ;
    }
    
    Point position = new Point(p);

    SwingUtilities.convertPointToScreen(position, c);

    StringBuilder caption = new StringBuilder();
    List<OverrideDescription> descriptions = new LinkedList<OverrideDescription>();
    boolean first = true;

    for (Entry<String, List<OverrideDescription>> e : caption2Descriptions.entrySet()) {
        if (!first) {
            caption.append("/");
        }
        first = false;
        caption.append(e.getKey());
        descriptions.addAll(e.getValue());
    }

    PopupUtil.showPopup(new IsOverriddenPopup(caption.toString(), descriptions), caption.toString(), position.x, position.y, true, 0);
}
 
源代码18 项目: netbeans   文件: PopupUtil.java
private static void resizePopup() {
    popupWindow.pack();
    Point point = new Point(0, 0);
    SwingUtilities.convertPointToScreen(point, getMainWindow());
    popupWindow.setLocation(point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2,
                             point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3);
}
 
源代码19 项目: ramus   文件: Handler.java
@Override
public void mouseReleased(final MouseEvent me) {
    if (!ourToolBarIsDragging)
        return;

    if ((me.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK) {
        return;
    }

    hideDraggingWindow();

    final Container target = ourDockLayout.getTargetContainer();
    if (target == null)
        return;

    Point p = me.getPoint();
    p = SwingUtilities.convertPoint(ourToolBar, p, target);

    DockBoundary dock = null;

    if (!me.isControlDown()) {
        dock = getDockableBoundary(p);
        if (dock != null) {
            setDockIndex(dock.getDockIndex(p));
            setRowIndex(dock.getRowIndex(p));
            setDockEdge(dock.getEdge());
        }
    }

    if (dock != null) {
        dockToolBar(getDockEdge(), getRowIndex(), getDockIndex());
    } else {
        SwingUtilities.convertPointToScreen(p, target);
        floatToolBar(p.x, p.y, true);
    }

}
 
源代码20 项目: netbeans   文件: CodeEvaluatorUI.java
private JButton createDropDownButton() {
    Icon icon = ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/evaluator/drop_down_arrow.png", false);
    final JButton button = new DropDownButton();
    button.setIcon(icon);
    String tooltipText = NbBundle.getMessage(CodeEvaluatorUI.class, "CTL_Expressions_Dropdown_tooltip");
    button.setToolTipText(tooltipText);
    button.setEnabled(false);
    Dimension size = new Dimension(icon.getIconWidth() + 3, icon.getIconHeight() + 2);
    button.setPreferredSize(size);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setFocusable(false);
    AbstractAction action = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if ("pressed".equals(e.getActionCommand())) {
                JComponent jc = (JComponent) e.getSource();
                Point p = new Point(0, 0);
                SwingUtilities.convertPointToScreen(p, jc);
                if (!ButtonPopupSwitcher.isShown()) {
                    SwitcherTableItem[] items = createSwitcherItems();
                    ButtonPopupSwitcher.selectItem(jc, items, p.x, p.y);
                }
                //Other portion of issue 37487, looks funny if the
                //button becomes pressed
                if (jc instanceof AbstractButton) {
                    AbstractButton jb = (AbstractButton) jc;
                    jb.getModel().setPressed(false);
                    jb.getModel().setRollover(false);
                    jb.getModel().setArmed(false);
                    jb.repaint();
                }
            }
        } // actionPerformed

        @Override
        public boolean isEnabled() {
            return !getEditItemsList().isEmpty();
        }

    };
    action.putValue(Action.SMALL_ICON, icon);
    action.putValue(Action.SHORT_DESCRIPTION, tooltipText);
    button.setAction(action);
    return button;
}