--- old/src/java.desktop/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java 2019-05-20 08:21:10.000000000 -0700 +++ new/src/java.desktop/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java 2019-05-20 08:21:08.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,14 @@ import java.util.ArrayList; import sun.util.logging.PlatformLogger; +import java.util.Enumeration; +import sun.awt.SunToolkit; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; +import javax.swing.ButtonModel; +import javax.swing.JToggleButton; + + /** * A FocusTraversalPolicy that determines traversal order based on the order * of child Components in a Container. From a particular focus cycle root, the @@ -585,6 +593,30 @@ return false; } + if (SunToolkit.isInstanceOf(aComponent, + "javax.swing.JToggleButton")) { + ButtonModel model = ((JToggleButton)aComponent).getModel(); + if (model != null) { + ButtonGroup group = model.getGroup(); + if (group != null) { + Enumeration elements = + group.getElements(); + int idx = 0; + while (group.getElements().hasMoreElements()) { + AbstractButton member = elements.nextElement(); + if (member instanceof JToggleButton && + member.isVisible() && member.isDisplayable() && + member.isEnabled() && member.isFocusable()) { + if (member == aComponent) { + return idx == 0; + } + idx++; + } + } + } + } + } + // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not.