United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7112115 Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
7112115 : Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel

Details
Type:
Bug
Submit Date:
2011-11-15
Status:
Closed
Updated Date:
2012-06-25
Project Name:
JDK
Resolved Date:
2012-06-25
Component:
client-libs
OS:
linux_oracle_5.6,generic,linux_oracle_6.0
Sub-Component:
java.awt
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u29,7,7u6
Fixed Versions:
8

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

Description
2 tests failed on oel5.6 because getLocationOnScreen() return wrong value:
java/awt/Component/NativeInLightShow/NativeInLightShow.html (test need modification before execution - CR 7102766)
javax/swing/JSpinner/5012888/bug5012888.java

see also http://java.net/jira/browse/MACOSX_PORT-618

tests failed only if GNOME panel (taskbar) is on top; 
test will pass if set location with non-zero y, for example, add line in bug5012888.java:
b.setLocation(0, 100);

values of getLocationOnScreen() after robot actions differ from values obtained before robot start work

tests passed on ubuntu 10 x64 (stt-28.ru), windows xp (karatedo.ru) and solaris 11 sparc (stt-73.ru) with taskbar on top

both tests failed with jdk1.6.0b105 and jdk1.5.0_33b09

java/awt/Component/NativeInLightShow/NativeInLightShow.html passed with jdk1.7.0_03b01
javax/swing/JSpinner/5012888/bug5012888.java failed with jdk1.7.0_03b01

see comments for more details
test java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java also failed with "top" panel orientation and passed with "bottom" on uel 6 (stt-66.ru)

log file http://stt-13.ru.oracle.com/results/1.6.0_31/b22_j4b/regression/uel6-x64-64/1.6.0_31b22_j4b-uel6-x64-64_j2se_java_gui_02/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.jtr

                                    

Comments
SUGGESTED FIX

http://hg.openjdk.java.net/jdk8/awt/jdk/rev/fd27852f3ea5
                                     
2012-05-30
EVALUATION

The problem happens with a pure AWT test.

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

public class LocationOnScreenTestAWT {
    public static void main (String ... args) {
        Frame f = new Frame();
        Panel panel = new Panel();
// setBounds() invoaction leads to different results for the label location.
        f.setBounds(0, 0, 100, 100);
        f.add(panel);
        Label js1 = new Label("label 1");
        Label js2 = new Label("label 2");
        panel.add(js1);
        panel.add(js2);
        f.setVisible(true);

        Point p = js2.getLocationOnScreen();

        while (true) {
            try {
                Point tp = js2.getLocationOnScreen();
                if (p.getX()!=tp.getX() || p.getY()!=tp.getY()) {
                    System.err.println("Location on screen: " + js2.getLocationOnScreen());
                    p = tp;
                }
            } catch (Exception e) {
                System.err.println(e.getMessage());
                continue;
            }
        }
    }
}

=====
Output:
Location on screen: java.awt.Point[x=26,y=55]
Location on screen: java.awt.Point[x=51,y=55]
                                     
2012-05-25
EVALUATION

I have added Thread.sleep(1000) before invocation of getLocationOnScreen()


$ /export/jdk/jdk1.7.0_05b03/bin/java bug5012888
pinner2.getLocationOnScreen() 1:java.awt.Point[x=5,y=75]
< === 1000
pinner2.getLocationOnScreen() 2:java.awt.Point[x=30,y=75]
pinner2.getLocationOnScreen() 2:java.awt.Point[x=30,y=75]

Looks like we have a time gap before shoiwing the component then we do not throw IllegalComponentStateException.
                                     
2012-05-23
EVALUATION

Initially I noticed that the problem is not always reproducible wth jdk7u4b10. So I looked for a timing. It seems there is no delay betwean setVisivble() and a obot click. I have added a delay and  the test passes always now.
                                     
2012-03-01
EVALUATION

reproduced on 7u2, please evaluate.
                                     
2012-02-28



Hardware and Software, Engineered to Work Together