Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8370627

motif look and feel focus traversal order may vary depending on the system version

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8, 11, 17, 21, 26
    • client-libs
    • None

      The issue was discovered in JDK-8316274.

      javax/swing/ButtonGroup/TestButtonGroupFocusTraversal.java
      the test started to fail on Ubuntu 23.10+
      This was revealed due to another bug (JDK-8370624).

      1. Only Motif LaF is affected.

      java.awt.DefaultKeyboardFocusManager#focusNextComponent returns different components depending on the system on which it is run

      Ubuntu 22.04 - the test passes, focus moves to JToggleButton
      Ubuntu 23.10+ - failure, focus moves to JRadioButton

      java.awt.DefaultKeyboardFocusManager#focusNextComponent call SortingFocusTraversalPolicy#getFocusTraversalCycle()
      https://github.com/openjdk/jdk/blob/3e20a9392fecef796098507acef429ef2d45a3d2/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java#L117

      which uses LayoutComparator
      https://github.com/openjdk/jdk/blob/3e20a9392fecef796098507acef429ef2d45a3d2/src/java.desktop/share/classes/javax/swing/LayoutComparator.java#L130-L134


      The JToggleButton and JRadioButton have different component bounds on Ubuntu 22.04 and 24.04:

      https://bugs.openjdk.org/secure/attachment/116610/TestButtonGroupFocusTraversal.java
      a modified test that includes a copy of the LayoutComparator with debug prints.

      # 22.04

      Comparing javax.swing.JToggleButton to javax.swing.JRadioButton

              ax = 42, ay = 14, bx = 118, by = 5
              zOrder = -2
              Math.abs(ay - by) < ROW_TOLERANCE Math.abs(14 - 5) = 9 < 10 = true
              (ax < bx) ? -1 : ((ax > bx) ? 1 : zOrder) -1
      RESULT: -1


      # 24.04

      Comparing javax.swing.JToggleButton to javax.swing.JRadioButton

              ax = 39, ay = 15, bx = 115, by = 5
              zOrder = -2
              Math.abs(ay - by) < ROW_TOLERANCE Math.abs(15 - 5) = 10 < 10 = false
              (ay < by) ? -1 : 1 : zOrder) 1
      RESULT: 1

      Note that, in the case of Ubuntu 24.04, Math.abs(ay - by) < ROW_TOLERANCE is not less that ROW_TOLERANCE, so, it's sorted differently.

            azvegint Alexander Zvegintsev
            azvegint Alexander Zvegintsev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: