Comment 0 for bug 1110138

Revision history for this message
bastik (bstk) wrote :

In Java applications, the functions to set and get window dimensions and position do not work as expected. This problem is only observed in Unity but not gnome, Win., etc.

Details:

* Call setSize(200, 200) and setLocation(300,400) for a JDialog object.

* If you call getSize() and getLocation() directly after making the JDialog visible, the result will be (200,200) and (300,400). Calling getSize() and getLocation() again, a split second later, the result is now (200,200) and (301,428). In both cases, the values are wrong, the size and location is actually (202,229) and (300,400) as shown by a screen capture.

Consequences:

* If the dialog is designed to reach to the bottom of the screen, the lower end will be cut off about 30 pixel, so the window needs to be moved by the user each time to see the lower button row (e.g. settings dialog in netbeans on medium resolution screen).

* In applications that save and restore window position and size, the window will move down 28 pixel each time it is opened an closed (e.g. JOSM, preference dialog).

Expected behavior:

* The result of getLocation() should be constant for one window unless the user moves the window

* setSize(dx,dy) should not set the size of the content pane, but the size of the entire window, including window decorations

* be consistent for all Window objects, e.g. in the attached sample, the JFrame works correctly, but the JDialog shows the described bug

Output of the sample code (press button "click", then press button "click2"):

dlg.getLocationOnScreen()=java.awt.Point[x=300,y=400]
dlg.getLocationOnScreen()=java.awt.Point[x=301,y=428]

Note: Both getLocation() and getLocationOnScreen() return the same values.

Observed for the following Java versions:

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

and

java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.4) (7u9-2.3.4-0ubuntu1.12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

Ubuntu 12.10

unity-6.12.0-0ubuntu0.2