sun.awt.ComponentFactory Java Examples

The following examples show how to use sun.awt.ComponentFactory. 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: PointerInfoCrashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testMouseInfoPeer() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        ComponentFactory componentFactory = (ComponentFactory) toolkit;

        MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();
        mouseInfoPeer.fillPointWithCoords(new Point());

        Window win = new Window(null);
        win.setSize(300, 300);
        win.setVisible(true);

        mouseInfoPeer.isWindowUnderMouse(win);
        win.dispose();
    }
}
 
Example #2
Source File: Robot.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #3
Source File: Robot.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #4
Source File: Robot.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    gdLoc = screen.getDefaultConfiguration().getBounds().getLocation();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #5
Source File: Robot.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #6
Source File: Robot.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #7
Source File: Robot.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    gdLoc = screen.getDefaultConfiguration().getBounds().getLocation();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #8
Source File: Robot.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    gdLoc = screen.getDefaultConfiguration().getBounds().getLocation();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #9
Source File: Robot.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #10
Source File: Robot.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #11
Source File: Robot.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #12
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the peer of this {@code Font}.
 *
 * @return the peer of the {@code Font}.
 */
private FontPeer getFontPeer() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof ComponentFactory) {
            peer = ((ComponentFactory) tk).getFontPeer(name, style);
        }
    }
    return peer;
}
 
Example #13
Source File: MouseInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code PointerInfo} instance that represents the current
 * location of the mouse pointer.
 * The {@code GraphicsDevice} stored in this {@code PointerInfo}
 * contains the mouse pointer. The coordinate system used for the mouse position
 * depends on whether or not the {@code GraphicsDevice} is part of a virtual
 * screen device.
 * For virtual screen devices, the coordinates are given in the virtual
 * coordinate system, otherwise they are returned in the coordinate system
 * of the {@code GraphicsDevice}. See {@link GraphicsConfiguration}
 * for more information about the virtual screen devices.
 * On systems without a mouse, returns {@code null}.
 * <p>
 * If there is a security manager, its {@code checkPermission} method
 * is called with an {@code AWTPermission("watchMousePointer")}
 * permission before creating and returning a {@code PointerInfo}
 * object. This may result in a {@code SecurityException}.
 *
 * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
 * @exception SecurityException if a security manager exists and its
 *            {@code checkPermission} method doesn't allow the operation
 * @see       GraphicsConfiguration
 * @see       SecurityManager#checkPermission
 * @see       java.awt.AWTPermission
 * @return    location of the mouse pointer
 * @since     1.5
 */
public static PointerInfo getPointerInfo() throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION);
    }

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Point point = new Point(0, 0);
    int deviceNum = 0;
    if (toolkit instanceof ComponentFactory) {
        deviceNum = ((ComponentFactory) toolkit).getMouseInfoPeer().fillPointWithCoords(point);
    }

    GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
                               getScreenDevices();
    PointerInfo retval = null;
    if (areScreenDevicesIndependent(gds)) {
        retval = new PointerInfo(gds[deviceNum], point);
    } else {
        for (int i = 0; i < gds.length; i++) {
            GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
            Rectangle bounds = gc.getBounds();
            if (bounds.contains(point)) {
                retval = new PointerInfo(gds[i], point);
            }
        }
    }

    return retval;
}
 
Example #14
Source File: Robot.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #15
Source File: MenuComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
final ComponentFactory getComponentFactory() {
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        return (ComponentFactory) toolkit;
    }
    throw new AWTError("UI components are unsupported by: " + toolkit);
}
 
Example #16
Source File: Font.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the peer of this {@code Font}.
 *
 * @return the peer of the {@code Font}.
 */
private FontPeer getFontPeer() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof ComponentFactory) {
            peer = ((ComponentFactory) tk).getFontPeer(name, style);
        }
    }
    return peer;
}
 
Example #17
Source File: MouseInfo.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a {@code PointerInfo} instance that represents the current
 * location of the mouse pointer.
 * The {@code GraphicsDevice} stored in this {@code PointerInfo}
 * contains the mouse pointer. The coordinate system used for the mouse position
 * depends on whether or not the {@code GraphicsDevice} is part of a virtual
 * screen device.
 * For virtual screen devices, the coordinates are given in the virtual
 * coordinate system, otherwise they are returned in the coordinate system
 * of the {@code GraphicsDevice}. See {@link GraphicsConfiguration}
 * for more information about the virtual screen devices.
 * On systems without a mouse, returns {@code null}.
 * <p>
 * If there is a security manager, its {@code checkPermission} method
 * is called with an {@code AWTPermission("watchMousePointer")}
 * permission before creating and returning a {@code PointerInfo}
 * object. This may result in a {@code SecurityException}.
 *
 * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
 * @exception SecurityException if a security manager exists and its
 *            {@code checkPermission} method doesn't allow the operation
 * @see       GraphicsConfiguration
 * @see       SecurityManager#checkPermission
 * @see       java.awt.AWTPermission
 * @return    location of the mouse pointer
 * @since     1.5
 */
public static PointerInfo getPointerInfo() throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION);
    }

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Point point = new Point(0, 0);
    int deviceNum = 0;
    if (toolkit instanceof ComponentFactory) {
        deviceNum = ((ComponentFactory) toolkit).getMouseInfoPeer().fillPointWithCoords(point);
    }

    GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
                               getScreenDevices();
    PointerInfo retval = null;
    if (areScreenDevicesIndependent(gds)) {
        retval = new PointerInfo(gds[deviceNum], point);
    } else {
        for (int i = 0; i < gds.length; i++) {
            GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
            Rectangle bounds = gc.getBounds();
            if (bounds.contains(point)) {
                retval = new PointerInfo(gds[i], point);
            }
        }
    }

    return retval;
}
 
Example #18
Source File: Robot.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
    }
    initLegalButtonMask();
}
 
Example #19
Source File: MenuComponent.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
final ComponentFactory getComponentFactory() {
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        return (ComponentFactory) toolkit;
    }
    throw new AWTError("UI components are unsupported by: " + toolkit);
}
 
Example #20
Source File: Robot.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #21
Source File: Robot.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #22
Source File: Robot.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #23
Source File: Robot.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #24
Source File: Robot.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #25
Source File: Robot.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void init(GraphicsDevice screen) throws AWTException {
    checkRobotAllowed();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        peer = ((ComponentFactory)toolkit).createRobot(this, screen);
        disposer = new RobotDisposer(peer);
        sun.java2d.Disposer.addRecord(anchor, disposer);
    }
    initLegalButtonMask();
}
 
Example #26
Source File: DataTransferer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * The accessor method for the singleton DataTransferer instance. Note
 * that in a headless environment, there may be no DataTransferer instance;
 * instead, null will be returned.
 */
public static synchronized DataTransferer getInstance() {
    return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
}
 
Example #27
Source File: DataTransferer.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * The accessor method for the singleton DataTransferer instance. Note
 * that in a headless environment, there may be no DataTransferer instance;
 * instead, null will be returned.
 */
public static synchronized DataTransferer getInstance() {
    return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
}
 
Example #28
Source File: DataTransferer.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * The accessor method for the singleton DataTransferer instance. Note
 * that in a headless environment, there may be no DataTransferer instance;
 * instead, null will be returned.
 */
public static synchronized DataTransferer getInstance() {
    return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
}
 
Example #29
Source File: DataTransferer.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * The accessor method for the singleton DataTransferer instance. Note
 * that in a headless environment, there may be no DataTransferer instance;
 * instead, null will be returned.
 */
public static synchronized DataTransferer getInstance() {
    return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
}
 
Example #30
Source File: DataTransferer.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * The accessor method for the singleton DataTransferer instance. Note
 * that in a headless environment, there may be no DataTransferer instance;
 * instead, null will be returned.
 */
public static synchronized DataTransferer getInstance() {
    return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
}