./test/java/awt/Multiscreen/LocationRelativeToTest/LocationRelativeToTest.java
Print this page
rev 293 : Revised check, if frame is placed at the center of the proper screen in
multi-screen environment.
@@ -48,11 +48,12 @@
{
Robot r = Util.createRobot();
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
- System.out.println("Center point: " + ge.getCenterPoint());
+ Point centerPoint = ge.getCenterPoint();
+ System.out.println("Center point: " + centerPoint);
GraphicsDevice[] gds = ge.getScreenDevices();
GraphicsDevice gdDef = ge.getDefaultScreenDevice();
GraphicsConfiguration gcDef =
gdDef.getDefaultConfiguration();
@@ -75,12 +76,11 @@
FRAME_WIDTH, FRAME_HEIGHT);
// second, check setLocationRelativeTo(invisible)
f.setLocationRelativeTo(f2);
Util.waitForIdle(r);
- checkLocation(f, new Point(gcBounds.x + gcBounds.width / 2,
- gcBounds.y + gcBounds.height / 2));
+ checkLocation(f, centerPoint);
// third, check setLocationRelativeTo(visible)
f2.setVisible(true);
Util.waitForIdle(r);
Point f2Loc = f2.getLocationOnScreen();