本文整理匯總了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) {
}
}