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


Java SunToolkit.getScreenInsets方法代码示例

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


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

示例1: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            createGui();
        }
    });

    toolkit.realSync();

    // Get screen insets
    screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
    if (screenInsets.bottom == 0) {
        // This test is only for configurations with taskbar on the bottom
        return;
    }

    System.setSecurityManager(new SecurityManager(){

        private String allowsAlwaysOnTopPermission = SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName();

        @Override
        public void checkPermission(Permission perm) {
            if (allowsAlwaysOnTopPermission.equals(perm.getName())) {
                throw new SecurityException();
            }
        }

    });

    // Show popup as if from an applet
    // The popup shouldn't overlap the task bar. It should be shifted up.
    checkPopup();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:bug6694823.java

示例2: testToolTip

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private static void testToolTip() throws AWTException {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.realSync();

    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = environment.getScreenDevices();
    for (GraphicsDevice device : devices) {
        GraphicsConfiguration[] configs = device.getConfigurations();
        for (GraphicsConfiguration config : configs) {
            Rectangle rect = config.getBounds();
            Insets insets = toolkit.getScreenInsets(config);
            adjustInsets(rect, insets);

            // Upper left
            glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
                    rect.x + MARGIN, rect.y + MARGIN);
            toolkit.realSync();

            // Lower left
            glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
                    rect.x + MARGIN, rect.y + rect.height - MARGIN);
            toolkit.realSync();

            // Upper right
            glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
                    rect.x + rect.width - MARGIN, rect.y + MARGIN);
            toolkit.realSync();

            // Lower right
            glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
                    rect.x + rect.width - MARGIN, rect.y + rect.height - MARGIN);
            toolkit.realSync();
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:bug7123767.java


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