本文整理汇总了Java中java.awt.GraphicsEnvironment.getMaximumWindowBounds方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsEnvironment.getMaximumWindowBounds方法的具体用法?Java GraphicsEnvironment.getMaximumWindowBounds怎么用?Java GraphicsEnvironment.getMaximumWindowBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.GraphicsEnvironment
的用法示例。
在下文中一共展示了GraphicsEnvironment.getMaximumWindowBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getScreenBoundsForPoint
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
/**
* Returns the screen coordinates for the monitor that contains the
* specified point. This is useful for setups with multiple monitors,
* to ensure that popup windows are positioned properly.
*
* @param x The x-coordinate, in screen coordinates.
* @param y The y-coordinate, in screen coordinates.
* @return The bounds of the monitor that contains the specified point.
*/
public static Rectangle getScreenBoundsForPoint(int x, int y) {
GraphicsEnvironment env = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
for (int i=0; i<devices.length; i++) {
GraphicsConfiguration[] configs = devices[i].getConfigurations();
for (int j=0; j<configs.length; j++) {
Rectangle gcBounds = configs[j].getBounds();
if (gcBounds.contains(x, y)) {
return gcBounds;
}
}
}
// If point is outside all monitors, default to default monitor (?)
return env.getMaximumWindowBounds();
}
示例2: getScreenBoundsForPoint
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
/**
* Returns the screen coordinates for the monitor that contains the
* specified point. This is useful for setups with multiple monitors,
* to ensure that popup windows are positioned properly.
*
* @param x The x-coordinate, in screen coordinates.
* @param y The y-coordinate, in screen coordinates.
* @return The bounds of the monitor that contains the specified point.
*/
public static Rectangle getScreenBoundsForPoint(int x, int y) {
GraphicsEnvironment env = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
for (int i=0; i<devices.length; i++) {
GraphicsConfiguration config = devices[i].getDefaultConfiguration();
Rectangle gcBounds = config.getBounds();
if (gcBounds.contains(x, y)) {
return gcBounds;
}
}
// If point is outside all monitors, default to default monitor (?)
return env.getMaximumWindowBounds();
}
示例3: run
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
@Override
public void run() {
try {
boolean animateFromBottom = true;
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
Rectangle screenRect = ge.getMaximumWindowBounds();
int screenHeight = (int) screenRect.height;
int startYPosition;
int stopYPosition;
if (screenRect.y > 0) {
animateFromBottom = false; // Animate from top!
}
maxToasterInSceen = screenHeight / toasterHeight;
int posx = (int) screenRect.width - toasterWidth - 1;
toaster.setLocation(posx, screenHeight);
toaster.setVisible(true);
if (useAlwaysOnTop) {
toaster.setAlwaysOnTop(true);
}
if (animateFromBottom) {
startYPosition = screenHeight;
stopYPosition = startYPosition - toasterHeight - 1;
if (currentNumberOfToaster > 0) {
stopYPosition = stopYPosition - (maxToaster % maxToasterInSceen * toasterHeight);
} else {
maxToaster = 0;
}
} else {
startYPosition = screenRect.y - toasterHeight;
stopYPosition = screenRect.y;
if (currentNumberOfToaster > 0) {
stopYPosition = stopYPosition + (maxToaster % maxToasterInSceen * toasterHeight);
} else {
maxToaster = 0;
}
}
currentNumberOfToaster++;
maxToaster++;
animateVertically(posx, startYPosition, stopYPosition);
Thread.sleep(displayTime);
animateVertically(posx, stopYPosition, startYPosition);
currentNumberOfToaster--;
toaster.setVisible(false);
toaster.dispose();
} catch (Exception e) {
Logger.getLogger(Toaster.class.getName()).log(Level.SEVERE, null, e);
}
}
示例4: run
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
@Override
public void run() {
try {
boolean animateFromBottom = true;
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
Rectangle screenRect = ge.getMaximumWindowBounds();
int screenHeight = (int) screenRect.height;
int startYPosition;
int stopYPosition;
if (screenRect.y > 0) {
animateFromBottom = false; // Animate from top!
}
maxToasterInSceen = screenHeight / toasterHeight;
int posx = (int) screenRect.width - toasterWidth - 1;
toaster.setLocation(posx, screenHeight);
toaster.setVisible(true);
if (useAlwaysOnTop) {
toaster.setAlwaysOnTop(true);
}
if (animateFromBottom) {
startYPosition = screenHeight;
stopYPosition = startYPosition - toasterHeight - 1;
if (currentNumberOfToaster > 0) {
stopYPosition = stopYPosition - (maxToaster % maxToasterInSceen * toasterHeight);
} else {
maxToaster = 0;
}
} else {
startYPosition = screenRect.y - toasterHeight;
stopYPosition = screenRect.y;
if (currentNumberOfToaster > 0) {
stopYPosition = stopYPosition + (maxToaster % maxToasterInSceen * toasterHeight);
} else {
maxToaster = 0;
}
}
currentNumberOfToaster++;
maxToaster++;
animateVertically(posx, startYPosition, stopYPosition);
Thread.sleep(displayTime);
animateVertically(posx, stopYPosition, startYPosition);
currentNumberOfToaster--;
toaster.setVisible(false);
toaster.dispose();
} catch (Exception e) {
}
}