< prev index next >
test/jdk/java/awt/Frame/MaximizedToOppositeScreen/MaximizedToOppositeScreenSmall.java
Print this page
rev 60071 : 8211999: Window positioning bugs due to overlapping GraphicsDevice bounds (Windows/HiDPI)
Reviewed-by: XXX
@@ -19,20 +19,21 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
/**
* @test
- * @bug 8176359 8231564
+ * @bug 8176359 8231564 8211999
* @key headful
* @requires (os.family == "windows" | os.family == "mac")
* @summary setMaximizedBounds() should work if set to the screen other than
* current screen of the Frame, the size of the frame is intentionally
* small
@@ -56,19 +57,27 @@
Robot robot = new Robot();
for (GraphicsDevice gd1 : gds) {
Rectangle framAt = gd1.getDefaultConfiguration().getBounds();
framAt.grow(-framAt.width / 2 + 100, -framAt.height / 2 + 100);
for (GraphicsDevice gd2 : gds) {
- Rectangle maxTo = gd2.getDefaultConfiguration().getBounds();
- maxTo.grow(-maxTo.width / 2 + 120, -maxTo.height / 2 + 120);
Frame frame = new Frame(gd1.getDefaultConfiguration());
try {
+ frame.setLayout(null); // trigger use the minimum size of
+ // the peer
frame.setBounds(framAt);
+
frame.setVisible(true);
robot.waitForIdle();
robot.delay(1000);
+ Dimension minimumSize = frame.getMinimumSize();
+ minimumSize.width = Math.max(minimumSize.width, 120);
+ minimumSize.height = Math.max(minimumSize.height, 120);
+ Rectangle maxTo = gd2.getDefaultConfiguration().getBounds();
+ maxTo.grow(-maxTo.width / 2 + minimumSize.width,
+ -maxTo.height / 2 + minimumSize.height);
+
frame.setMaximizedBounds(maxTo);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
robot.waitForIdle();
robot.delay(1000);
< prev index next >