JDK-8065739 : [macosx] Frame warps to lower left of screen when displayed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-11-08
  • Updated: 2015-07-24
  • Resolved: 2015-05-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b68Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
MacOS 10.9.5, 10.10

A DESCRIPTION OF THE PROBLEM :
I have found that displaying a frame can cause the frame to warp to the lower left corner of the screen, similar to the effect reported in bug 8032595 (which is reportedly fixed in this release). Two conditions appear to be necessary: Before making the frame visible, the frame is first packed, then resized with a height close to or greater than the available screen height.


REGRESSION.  Last worked in version 7u45

ADDITIONAL REGRESSION INFORMATION: 
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following test program illustrates.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The frame should be visible and (nearly) fill the screen.
ACTUAL -
The top of the frame is near the bottom of the screen, so that the frame is mostly not visible.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;

import javax.swing.*;
import java.awt.*;

public class Main
{
    public Main()
    {
        int offset = 10;    // the bug happens when offset is <= 10
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        Rectangle gb = gc.getBounds();
        Insets s = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        Rectangle r = new Rectangle(gb.x + s.left, gb.y + s.top, gb.width - s.left - s.right, gb.height - s.top - s.bottom - offset);
        final JFrame w = new JFrame();
        w.pack();   // necessary to show the bug
        w.setBounds(r);
        w.setVisible(true);
    }

    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new Main();
            }
        });
    }
}

// not affected by dock position or hiding
// not affected by screen menu bar
// happens in JDK 8u25, not in JDK 7

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Don't pack or don't make the frame too tall.


Comments
Mac OS X treats a window which has maximal sizes as zoomed and maximized. Frame.setVisible(true) checks that the window has NORMAL state by default tries to unmaximize it but zoom() operation leads that the window is zoomed to the previous size which is zero.
06-04-2015

Response from the submitter: "I tried my test program using 8u25 and 9 build 39. I ran it several times using both versions of Java. There was one time when the window displayed normally, but every other time it warped to the lower left of the screen. I also noticed small variations in the appearance of the window, see attached screen shots. I ran the program on OS 10.10.1 and 10.9.5 and I ran it in a guest account. The problem occurred in all those environments. Here is the problem on 10.9.5 (attached image) Here is the problem on 10.10.1 using a guest account. The dock is not visible because it has fewer items and does not reach the corner of the screen. (attached image) Both of these show display artifacts. They go away when I resize the window. My system is a 27��� Late 2009 iMac with ATI Radeon HD 4850 512 MB."
25-11-2014

please re-open once replied back
24-11-2014

Tested this with JDK 7u40, 8u25 and 8u40 on MAC OS X and couldn't reproduce the issue. Sent an email to submitter to reconfirm the status with 8u25 and JDK 9 (apparent fix, ref: JDK-8032595)
24-11-2014