United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6692619 Component is missing after changing the z-order of the component & focus is not transfered in
JDK-6692619 : Component is missing after changing the z-order of the component & focus is not transfered in

Details
Type:
Bug
Submit Date:
2008-04-23
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2008-04-26
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P1
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u10 (b23)

Related Reports
Backport:
Relates:

Sub Tasks

Description
I have a jframe which contains 4 buttons. I change the make the first button as the focus owner & change the z-order of the 2nd button, the component is shifted i,e z-order is applied but a component is remove or hidden . After i am pressing tab to change the focus , but focus is not transfered. This works fine in 6u10_b22 promoted build, fails in 6u10 b23 pit only. This is the regression of http://monaco.sfbay.sun.com/detail.jsf?cr=6616323-2161436. Hence its a regression introduced in pit build.  I have the screen shot of same .

Step to reproduce:-
---------------------
1) Run the attached program . This is an automated testcase.
2) Observe that after the z-order ( b1 is changing its position ) b3 is  missing & focus remains on b1 . If you see the same then the bug is reproduced.
This bug is reproduced also for awt components with the 6u10 b23 pit build.
However the component is not getting missed but the focus is not transferred to the 
required component after changing the ZOrder. 
getComponentZOrder(Component comp) method is not returing the proper ZOrder index of the component
after changing the ZOrder .

Steps to reproduce:

1. Run the attached automated testcase (ZOrder.java) 
2. Observe that after changing the ZOrder the focus is not transferred to the required component (After pressing tab)
3. Also observe that getComponentZOrder(Component comp) method is returing unexpected values.

Since this is a regression I am increasing the priority .

                                    

Comments
SUGGESTED FIX

I'm about to add a note about this into the code:
// According to the rules below we should remove component and then
// add it by the newIndex without newIndex decrement if even we shift components to the left
// after remove.
// 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
// 4->2: 012345 -> 014235
                                     
2008-04-23
EVALUATION

When removing the component delicately there is some additional check exists: 
    if (newIndex > index) { 
        newIndex--;
    }
Which were introduced while fixing 6616323 by mistake which is described in the comment just above that extra check:
// If we first remove a component before adding it into higher index (newIndex), 
// then newIndex should be decremented.
But there are also several examples that contradict that statement:
// 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
// 4->2: 012345 -> 014235
So far, even we shift the components left by one position when removing particular element, it's still ok to push it by the newIndex without decrement.
                                     
2008-04-23



Hardware and Software, Engineered to Work Together