On Tue, 15 Feb 2022 02:48:54 GMT, Manukumar V S <m...@openjdk.org> wrote:

> Create a regression test for JDK-4514331.
> It checks whether pressing 'Tab' key always shift focus to next component, 
> even though the current focus is in JTextArea and some text is already 
> selected.
> 
> Testing:
> I have verified this test with JDK 1.3.1 and JDK 1.4.1 .
> The issue is reproducible with JDK 1.3.1 and the test failed there, where the 
> bug was originally reported and the test passed in JDK 1.4.1 where the issue 
> was fixed.
> I have tested it in Linux, Mac and Windows platforms and it passed everywhere.

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 
72:

> 70:                 SwingUtilities.invokeAndWait(() -> {
> 71:                     setLookAndFeel(laf);
> 72:                     createUI();

I suggest calling waitForIdle after the window creation and before 
editor.getLocationOnScreen();

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 
75:

> 73:                 });
> 74:                 passed = false;
> 75:                 Point editorLoc = editor.getLocationOnScreen();

The editor is a Swing component, should be accessed on EDT.

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 
100:

> 98:         editor.setEditable(false);
> 99:         editor.requestFocusInWindow();
> 100:         panel.add(editor);

I am not sure that this will work all the time, the requestFocusInWindow(), see 
part of the spec:
>  * This component must be displayable, focusable, visible
    * and all of its ancestors (with the exception of the top-level
    * Window) must be visible for the request to be granted

-------------

PR: https://git.openjdk.java.net/jdk/pull/7469

Reply via email to