On Thu, 17 Feb 2022 09:56:45 GMT, Srinivas Mandalika <smandal...@openjdk.org> wrote:
> Create a regression test for CCC8000326 > > Issue is identified by > [JDK-8000326](https://bugs.openjdk.java.net/browse/JDK-8000326), which > identifies that after focus moves into JMenuBar, whose focus traversal key is > disabled by default, it never moves to other focusable component. > > By default, pressing the Tab key does not transfer focus from a JMenuBar > which is added to a container together with other Swing components, because > the focusTraversalKeysEnabled property of JMenuBar is set to false. To > resolve this, you should call the JMenuBar.setFocusTraversalKeysEnabled(true) > method. > > The test verifies focus traversal for the above described scenario. Changes requested by aivanov (Reviewer). test/jdk/java/awt/Focus/CCC8000326/CCC8000326.java line 46: > 44: import javax.swing.SwingUtilities; > 45: > 46: public class CCC8000326 { I suggest giving a descriptive class name. Please omit `CCC` from the path: `…/Focus/8000326/TestName.java`. test/jdk/java/awt/Focus/CCC8000326/CCC8000326.java line 49: > 47: > 48: private static JFrame jFrame; > 49: private static Component currentFocusOwner; Both `jFrame` and `currentFocusOwner` should be declared `volatile`, both accessed from different threads. test/jdk/java/awt/Focus/CCC8000326/CCC8000326.java line 61: > 59: Component lastFocusOwner = null; > 60: do { > 61: SwingUtilities.invokeAndWait(() -> { You should call `robot.waitForIdle();` as the first statement inside the loop: it'll handle both the initial iteration and the following ones to allow the EDT to process `Tab` key. The call to `waitForIdle` at line 64 after getting the focus owner seems redundant because you don't modify the state of the UI on line 62 but only read its current state. test/jdk/java/awt/Focus/CCC8000326/CCC8000326.java line 75: > 73: } while (currentFocusOwner != jFrame); > 74: } finally { > 75: jFrame.dispose(); Must be called on EDT. test/jdk/java/awt/Focus/CCC8000326/CCC8000326.java line 105: > 103: > 104: CCC8000326.doTest(); > 105: Suggestion: doTest(); ------------- PR: https://git.openjdk.java.net/jdk/pull/7512