本文整理汇总了Java中java.awt.GraphicsEnvironment.getScreenDevices方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsEnvironment.getScreenDevices方法的具体用法?Java GraphicsEnvironment.getScreenDevices怎么用?Java GraphicsEnvironment.getScreenDevices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.GraphicsEnvironment
的用法示例。
在下文中一共展示了GraphicsEnvironment.getScreenDevices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
robot = new Robot();
robot.setAutoDelay(100);
robot.setAutoWaitForIdle(true);
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] sds = ge.getScreenDevices();
UIManager.LookAndFeelInfo[] lookAndFeelArray =
UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
System.setProperty(PROPERTY_NAME, "true");
step(sds, lookAndFeelItem);
if (lookAndFeelItem.getClassName().contains("Aqua")) {
System.setProperty(PROPERTY_NAME, "false");
step(sds, lookAndFeelItem);
}
}
}
示例2: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] sds = ge.getScreenDevices();
for (GraphicsDevice sd : sds) {
GraphicsConfiguration gc = sd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Point point = new Point(bounds.x, bounds.y);
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
while (point.y < bounds.y + bounds.height - insets.bottom - SIZE) {
while (point.x
< bounds.x + bounds.width - insets.right - SIZE) {
test(point);
point.translate(bounds.width / 5, 0);
}
point.setLocation(bounds.x, point.y + bounds.height / 5);
}
}
}
示例3: getScreens
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
/**
* Returns an array of screens that are available on the current system
*
* @return
*/
public static ScreenModel[] getScreens() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gd = ge.getScreenDevices();
ScreenModel[] models = new ScreenModel[gd.length];
for (int i = 0; i < gd.length; i++) {
if (gd[i].getIDstring().equals(getDefaultScreenId())) {
models[i] = new ScreenModel(gd[i], "(" + I18n.get("settings.mainscreen") + ")", i + 1);
} else {
models[i] = new ScreenModel(gd[i], "", i + 1);
}
}
return models;
}
示例4: getScreenRefreshRate
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
int getScreenRefreshRate() {
int rate = 60;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (int i = 0; i < gs.length; i++) {
DisplayMode dm = gs[i].getDisplayMode();
// Get refresh rate in Hz
int refreshRate = dm.getRefreshRate();
if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
// log.warning("MotionViewer.getScreenRefreshRate: got unknown refresh rate for screen "+i+", assuming 60");
refreshRate = 60;
} else {
// log.info("MotionViewer.getScreenRefreshRate: screen "+i+" has refresh rate "+refreshRate);
}
if (i == 0) {
rate = refreshRate;
}
}
return rate;
}
示例5: getScreenRefreshRate
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
int getScreenRefreshRate() {
int rate = 60;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (ge == null) {
return rate;
}
GraphicsDevice[] gs = ge.getScreenDevices();
for (int i = 0; i < gs.length; i++) {
DisplayMode dm = gs[i].getDisplayMode();
// Get refresh rate in Hz
if (dm == null) {
return rate;
}
int refreshRate = dm.getRefreshRate();
if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
log.warning("AEViewer.getScreenRefreshRate: got unknown refresh rate for screen " + i + ", assuming 60");
refreshRate = 60;
} else {
// log.info("AEViewer.getScreenRefreshRate: screen "+i+" has refresh rate "+refreshRate);
}
if (i == 0) {
rate = refreshRate;
}
}
return rate;
}
示例6: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
robot = new Robot();
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
UIManager.LookAndFeelInfo[] lookAndFeelArray =
UIManager.getInstalledLookAndFeels();
for (GraphicsDevice sd : ge.getScreenDevices()) {
for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
executeCase(lookAndFeelItem.getClassName(), sd);
robot.waitForIdle();
}
}
}
示例7: setScreenAndDimensions
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
private void setScreenAndDimensions(JFrame frame) {
// check multiple displays
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String display = Config.instance().to().getString(Config.Entry.SCREEN.key(), "-");
GraphicsDevice[] screens = ge.getScreenDevices();
if (screens.length == 1) {
setDimensions(frame,
Config.instance().to().getInt(Config.Entry.POS_X.key(), -1),
Config.instance().to().getInt(Config.Entry.POS_Y.key(), -1),
Config.instance().to().getInt(Config.Entry.POS_WIDTH.key(), -1),
Config.instance().to().getInt(Config.Entry.POS_HEIGHT.key(), -1));
} else {
for (GraphicsDevice screen : screens) { // if multiple screens available then try to open on saved display
if (screen.getIDstring().contentEquals(display)) {
JFrame dummy = new JFrame(screen.getDefaultConfiguration());
frame.setLocationRelativeTo(dummy);
dummy.dispose();
Rectangle screenBounds = screen.getDefaultConfiguration().getBounds();
Point pos = new Point(Config.instance().to().getInt(Config.Entry.SCREEN_POS_X.key(), -1),
Config.instance().to().getInt(Config.Entry.SCREEN_POS_Y.key(), -1));
if (pos.x >= 0 && pos.y >= 0) {
pos.x += screenBounds.x;
pos.y += screenBounds.y;
logger.info(" new pos {} {} ", pos.x, pos.y);
}
setDimensions(frame,
pos.x,
pos.y,
Config.instance().to().getInt(Config.Entry.SCREEN_POS_WIDTH.key(), -1),
Config.instance().to().getInt(Config.Entry.SCREEN_POS_HEIGHT.key(), -1));
break;
}
}
}
}
示例8: show
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
void show(Point location) {
Rectangle screenBounds = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice device : gds) {
GraphicsConfiguration gc = device.getDefaultConfiguration();
screenBounds = gc.getBounds();
if (screenBounds.contains(location)) {
break;
}
}
// showing the popup tooltip
cp = new TooltipContentPanel();
Window w = SwingUtilities.windowForComponent(parent);
contentWindow = new JWindow(w);
contentWindow.add(cp);
contentWindow.pack();
Dimension dim = contentWindow.getSize();
if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) {
// the whole window does fully not fit to the right
// the x position where the window has to start to fully fit to the right
int left = screenBounds.width + screenBounds.x - cp.longestLine;
// the window should have x pos minimally at the screen's start
location.x = Math.max(screenBounds.x, left);
}
if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
}
if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
}
contentWindow.setSize(dim);
contentWindow.setLocation(location.x, location.y + 1); // slight visual adjustment
contentWindow.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
cp.scrollRectToVisible(new Rectangle(1, 1));
}
});
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
w.addWindowFocusListener(this);
contentWindow.addWindowFocusListener(this);
contentWindow.addKeyListener(this);
w.addKeyListener(this);
}
示例9: isOutOfScreen
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
/**
* @return False if the given point is not inside any screen device that are currently available.
*/
private static boolean isOutOfScreen( int x, int y ) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for( int j=0; j<gs.length; j++ ) {
GraphicsDevice gd = gs[j];
if( gd.getType() != GraphicsDevice.TYPE_RASTER_SCREEN )
continue;
Rectangle bounds = gd.getDefaultConfiguration().getBounds();
if( bounds.contains( x, y ) )
return false;
}
return true;
}
示例10: isResolutionTooSmall
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
/**
*
* @return Returns true if a display has a too small resolution
*/
private boolean isResolutionTooSmall() {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] allScreens = env.getScreenDevices();
// check for all screen devices their display height
for (GraphicsDevice screen : allScreens) {
if (screen.getDefaultConfiguration().getBounds().getHeight() < MIN_RESOLUTION_HEIGHT) {
return true;
}
}
return false; // big icons are supported
}
示例11: getGraphicsConfigurationForPoint
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static GraphicsConfiguration getGraphicsConfigurationForPoint(Point l)
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for( GraphicsDevice gd : ge.getScreenDevices() )
{
GraphicsConfiguration gc = gd.getDefaultConfiguration();
if( gc.getBounds().contains(l) )
{
return gc;
}
}
return null;
}
示例12: 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();
}
示例13: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) throws AWTException
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multiscreen test... skipping!");
return;
}
for (int i = 0; i < gds.length; ++i) {
GraphicsDevice gd = gds[i];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle screen = gc.getBounds();
Robot robot = new Robot(gd);
// check Robot.mouseMove()
robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
Point mouse = MouseInfo.getPointerInfo().getLocation();
Point point = screen.getLocation();
point.translate(mouseOffset.x, mouseOffset.y);
if (!point.equals(mouse)) {
throw new RuntimeException(getErrorText("Robot.mouseMove", i));
}
// check Robot.getPixelColor()
Frame frame = new Frame(gc);
frame.setUndecorated(true);
frame.setSize(100, 100);
frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
frame.setBackground(color);
frame.setVisible(true);
robot.waitForIdle();
Rectangle bounds = frame.getBounds();
if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
}
// check Robot.createScreenCapture()
BufferedImage image = robot.createScreenCapture(bounds);
int rgb = color.getRGB();
if (image.getRGB(0, 0) != rgb
|| image.getRGB(image.getWidth() - 1, 0) != rgb
|| image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
|| image.getRGB(0, image.getHeight() - 1) != rgb) {
throw new RuntimeException(
getErrorText("Robot.createScreenCapture", i));
}
frame.dispose();
}
System.out.println("Test PASSED!");
}
示例14: saveScreenAndDimensions
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
private void saveScreenAndDimensions(JFrame frame) {
if (!frame.isVisible()) {
return;
}
// check multiple displays
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screens = ge.getScreenDevices();
Point pos = frame.getLocationOnScreen();
Dimension size = frame.getSize();
if (screens.length == 1) {
Config.instance().to().setProperty(Config.Entry.POS_X.key(), pos.x);
Config.instance().to().setProperty(Config.Entry.POS_Y.key(), pos.y);
Config.instance().to().setProperty(Config.Entry.POS_WIDTH.key(), size.width);
Config.instance().to().setProperty(Config.Entry.POS_HEIGHT.key(), size.height);
logger.info("Saved window dimensions to config file (single screen found)");
} else {
Rectangle screenBounds = frame.getGraphicsConfiguration().getBounds();
pos.x -= screenBounds.x;
pos.y -= screenBounds.y;
GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_X.key(), pos.x);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_Y.key(), pos.y);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_WIDTH.key(), size.width);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_HEIGHT.key(), size.height);
Config.instance().to().setProperty(Config.Entry.SCREEN.key(), device.getIDstring());
logger.info("Saved window dimensions to config file (multi screen found)");
}
}
示例15: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.
getLocalGraphicsEnvironment();
if (ge.isHeadlessInstance()) {
return;
}
for (GraphicsDevice gd : ge.getScreenDevices()) {
for (GraphicsConfiguration gc : gd.getConfigurations()) {
testScaleFactor(gc);
}
}
}