-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.2, 5.0, 6
-
generic
-
generic
If I make a component as focusTraversalPolicyProvider(RFE 4719336) and set its focus policy to ContainerOrderFocusTraversalPolicy than it
is not moving focus in the child components using traversal key as expected.
Attached are two tests AWTFocusTest.java & SwingFocusTest.java
Steps to reproduce:
a) Run either of test case AWTFocusTest/SwingFocusTest
b) Click on button "Start test"
c) This should move the focus to each textfield, But none of the
textfield gets focus, And so focusGained is never called.
Now go to line(Either of testcase) 19 and uncomment it and comment line 20.
Now run modified testcase, It will now use LayoutFocusTraversalPolicy,
Now run the test and it will move focus as expected and display following
console message
Expected component to get focus: Component 1
focusGained: Component 1
Expected component to get focus: Component 2
focusGained: Component 2
Expected component to get focus: Component 3
focusGained: Component 3
Following is the attached mail which have some discussion on this issue.
--------------------------------------------------------------------
Hi Hemant,
I've evaluated the problem you describe and I think this is a bug.
Could you pelase file it (please attache both Swing and AWT tests
to it).
With best regards, Oleg.
On Mon, Nov 24, 2003 at 03:18:26PM +0300, Roman S. Poborchy wrote:
>> Alright, we'll look into that.
>>
>> Hemant Singh wrote:
>>
>
>>> > Hi Roman,
>>> > Thanks for the time.
>>> >
>>> > Roman I have converted testcase(AWTFocusTest) to AWT & attached.
>>> > Problem still seems to be there.
>>> > Just like in swing here also LayoutFocusTraversalPolicy works fine but
>>> > ContainerOrderFocusTraversalPolicy not behaving as expected, Can you
>>> > have a look on it.
>>> >
>>> > The way you need to run the test remains the same, As this is same test
>>> > but now using AWT component/container instead of Swing component/container.
>>> >
>>> > Regards
>>> > Hemamt
>>> >
>>> > Attachment: AWTFocusTest.java
>>> >
>>> > Roman S. Poborchy wrote:
>>> >
>>
>>>> > > Hi Hemant,
>>>> > >
>>>> > > Hemant Singh wrote:
>>>> > >
>>>> > >
>>>
>>>>> > >>Sorry for sending you complete test case and indeed it was under development so was bit cluttered
>>>>> > >>also.
>>>>> > >>I have attached(AWTFocusTest) a small testcase specific to problem.
>>>>> > >>- I have tested it on Win2k and Solaris 5.8
>>>>> > >>Description about problem:
>>>>> > >>- Run the attached testcase.
>>>>> > >>- Click on button start test. This will make a thread which moves in current focus traversal
>>>>> > >>policy
>>>>> > >> till last component and press forward traversal key for each component and expects that
>>>>> > >>component
>>>>> > >> to receive focus on it.
>>>>> > >>When you will run it you should have output on console something like.
>>>>> > >>Expected component to get focus: Component 1
>>>>> > >> focusGained: Component 1
>>>>> > >>Expected component to get focus: Component 2
>>>>> > >> focusGained: Component 2
>>>>> > >>Expected component to get focus: Component 3
>>>>> > >> focusGained: Component 3
>>>>> > >>This is the output if I use LayoutFocusTraversalPolicy,
>>>>> > >>But now if you modify the test case(Comment line 17 and uncomment line 18) to use
>>>>> > >>ContainerOrderFocusTraversalPolicy
>>>>> > >>than it doesn't work as expected and components don't get focus on traversal key press.
>>>>> > >>Please ping me back If you have any problem in running or confusion about it at any point.
>>>
>>>> > >
>>>> > >
>>>> > > Now I've run this test and I think I know what the problem is.
>>>> > > ContainerOrderFocusTraversalPolicy can't work with Swing components and
>>>> > > Containers. If you write a pure AWT testcase (with Frame, Panels, Textields and
>>>> > > Buttons, for example), it will work with ContainerOrderFocusTraversalPolicy.
>>>> > > Likewise, LayoutFocusTraversalPolicy is going to have troubles with pure
>>>> > > AWT testcase.
>>>> > >
>>>> > > The problem is, it isn't mentioned anywhere in the doc that this policy shouldn't
>>>> > > be used for Swing components. We thought it would be enough to have the
>>>> > > correct policy select by default according to Container's type.
>>>> > >
>>>> > > So, doc clarification might be needed, but the behaviour is intended.
>>>> > >
>>>> > > Thanks,
>>>> > >
>>>> > > Roman
>>>> > >
>>
>>> >
>>> > ----------------------------------------------------------------------------------------------------
>>> > Name: AWTFocusTest.java
>>> > AWTFocusTest.java Type: Plain Text (text/plain)
>>> > Encoding: 7BIT
is not moving focus in the child components using traversal key as expected.
Attached are two tests AWTFocusTest.java & SwingFocusTest.java
Steps to reproduce:
a) Run either of test case AWTFocusTest/SwingFocusTest
b) Click on button "Start test"
c) This should move the focus to each textfield, But none of the
textfield gets focus, And so focusGained is never called.
Now go to line(Either of testcase) 19 and uncomment it and comment line 20.
Now run modified testcase, It will now use LayoutFocusTraversalPolicy,
Now run the test and it will move focus as expected and display following
console message
Expected component to get focus: Component 1
focusGained: Component 1
Expected component to get focus: Component 2
focusGained: Component 2
Expected component to get focus: Component 3
focusGained: Component 3
Following is the attached mail which have some discussion on this issue.
--------------------------------------------------------------------
Hi Hemant,
I've evaluated the problem you describe and I think this is a bug.
Could you pelase file it (please attache both Swing and AWT tests
to it).
With best regards, Oleg.
On Mon, Nov 24, 2003 at 03:18:26PM +0300, Roman S. Poborchy wrote:
>> Alright, we'll look into that.
>>
>> Hemant Singh wrote:
>>
>
>>> > Hi Roman,
>>> > Thanks for the time.
>>> >
>>> > Roman I have converted testcase(AWTFocusTest) to AWT & attached.
>>> > Problem still seems to be there.
>>> > Just like in swing here also LayoutFocusTraversalPolicy works fine but
>>> > ContainerOrderFocusTraversalPolicy not behaving as expected, Can you
>>> > have a look on it.
>>> >
>>> > The way you need to run the test remains the same, As this is same test
>>> > but now using AWT component/container instead of Swing component/container.
>>> >
>>> > Regards
>>> > Hemamt
>>> >
>>> > Attachment: AWTFocusTest.java
>>> >
>>> > Roman S. Poborchy wrote:
>>> >
>>
>>>> > > Hi Hemant,
>>>> > >
>>>> > > Hemant Singh wrote:
>>>> > >
>>>> > >
>>>
>>>>> > >>Sorry for sending you complete test case and indeed it was under development so was bit cluttered
>>>>> > >>also.
>>>>> > >>I have attached(AWTFocusTest) a small testcase specific to problem.
>>>>> > >>- I have tested it on Win2k and Solaris 5.8
>>>>> > >>Description about problem:
>>>>> > >>- Run the attached testcase.
>>>>> > >>- Click on button start test. This will make a thread which moves in current focus traversal
>>>>> > >>policy
>>>>> > >> till last component and press forward traversal key for each component and expects that
>>>>> > >>component
>>>>> > >> to receive focus on it.
>>>>> > >>When you will run it you should have output on console something like.
>>>>> > >>Expected component to get focus: Component 1
>>>>> > >> focusGained: Component 1
>>>>> > >>Expected component to get focus: Component 2
>>>>> > >> focusGained: Component 2
>>>>> > >>Expected component to get focus: Component 3
>>>>> > >> focusGained: Component 3
>>>>> > >>This is the output if I use LayoutFocusTraversalPolicy,
>>>>> > >>But now if you modify the test case(Comment line 17 and uncomment line 18) to use
>>>>> > >>ContainerOrderFocusTraversalPolicy
>>>>> > >>than it doesn't work as expected and components don't get focus on traversal key press.
>>>>> > >>Please ping me back If you have any problem in running or confusion about it at any point.
>>>
>>>> > >
>>>> > >
>>>> > > Now I've run this test and I think I know what the problem is.
>>>> > > ContainerOrderFocusTraversalPolicy can't work with Swing components and
>>>> > > Containers. If you write a pure AWT testcase (with Frame, Panels, Textields and
>>>> > > Buttons, for example), it will work with ContainerOrderFocusTraversalPolicy.
>>>> > > Likewise, LayoutFocusTraversalPolicy is going to have troubles with pure
>>>> > > AWT testcase.
>>>> > >
>>>> > > The problem is, it isn't mentioned anywhere in the doc that this policy shouldn't
>>>> > > be used for Swing components. We thought it would be enough to have the
>>>> > > correct policy select by default according to Container's type.
>>>> > >
>>>> > > So, doc clarification might be needed, but the behaviour is intended.
>>>> > >
>>>> > > Thanks,
>>>> > >
>>>> > > Roman
>>>> > >
>>
>>> >
>>> > ----------------------------------------------------------------------------------------------------
>>> > Name: AWTFocusTest.java
>>> > AWTFocusTest.java Type: Plain Text (text/plain)
>>> > Encoding: 7BIT
- relates to
-
JDK-8025001 setFocusTraversalPolicy() to ContainerOrderFocusTraversalPolicy results in an infinite loop
-
- Resolved
-
-
JDK-4719336 Ability for non focusCycleRoots to provide focusTraversalPolicy
-
- Resolved
-