当前位置: 首页>>代码示例>>Java>>正文


Java ComponentFactory类代码示例

本文整理汇总了Java中sun.awt.ComponentFactory的典型用法代码示例。如果您正苦于以下问题:Java ComponentFactory类的具体用法?Java ComponentFactory怎么用?Java ComponentFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ComponentFactory类属于sun.awt包,在下文中一共展示了ComponentFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMouseInfoPeer

import sun.awt.ComponentFactory; //导入依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PointerInfoCrashTest.java

示例2: findUnderMouseInWindow

import sun.awt.ComponentFactory; //导入依赖的package包/类
/**
 * Assuming that mouse location is stored in PointerInfo passed
 * to this method, it finds a Component that is in the same
 * Window as this Component and is located under the mouse pointer.
 * If no such Component exists, null is returned.
 * NOTE: this method should be called under the protection of
 * tree lock, as it is done in Component.getMousePosition() and
 * Container.getMousePosition(boolean).
 */
Component findUnderMouseInWindow(PointerInfo pi) {
    if (!isShowing()) {
        return null;
    }
    Window win = getContainingWindow();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (!(toolkit instanceof ComponentFactory)) {
        return null;
    }
    if (!((ComponentFactory) toolkit).getMouseInfoPeer().isWindowUnderMouse(win)) {
        return null;
    }
    final boolean INCLUDE_DISABLED = true;
    Point relativeToWindow = win.pointRelativeToComponent(pi.getLocation());
    Component inTheSameWindow = win.findComponentAt(relativeToWindow.x,
                                                    relativeToWindow.y,
                                                    INCLUDE_DISABLED);
    return inTheSameWindow;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:Component.java

示例3: init

import sun.awt.ComponentFactory; //导入依赖的package包/类
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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Robot.java

示例4: getComponentFactory

import sun.awt.ComponentFactory; //导入依赖的package包/类
final ComponentFactory getComponentFactory() {
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        return (ComponentFactory) toolkit;
    }
    throw new AWTError("UI components are unsupported by: " + toolkit);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:MenuComponent.java

示例5: getComponentFactory

import sun.awt.ComponentFactory; //导入依赖的package包/类
final ComponentFactory getComponentFactory() {
    final Toolkit toolkit = getToolkit();
    if (toolkit instanceof ComponentFactory) {
        return (ComponentFactory) toolkit;
    }
    throw new AWTError("UI components are unsupported by: " + toolkit);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Component.java

示例6: getPointerInfo

import sun.awt.ComponentFactory; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:MouseInfo.java

示例7: getFontPeer

import sun.awt.ComponentFactory; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Font.java

示例8: init

import sun.awt.ComponentFactory; //导入依赖的package包/类
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);
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:9,代码来源:Robot.java

示例9: init

import sun.awt.ComponentFactory; //导入依赖的package包/类
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();
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:12,代码来源:Robot.java

示例10: getInstance

import sun.awt.ComponentFactory; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:DataTransferer.java


注:本文中的sun.awt.ComponentFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。