本文整理汇总了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();
}
示例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();
}
}
}