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

FocusTraversalPolicy is overwritten with default when a new JFrame object is created

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 7
    • 5.0u18, 6u7, 6u12
    • client-libs
    • x86, sparc
    • solaris_10, windows_xp

        FocusTraversalPolicy is overwritten with default when a new JFrame object
        is created.

        The issue is strictly reproducible:

        1. Testcase
        -----------
        % more FocusManagerTest.java

        import java.awt.*;
        import javax.swing.*;

        public class FocusManagerTest {

          public static void main(String[] args) {

            KeyboardFocusManager currentKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
            ContainerOrderFocusTraversalPolicy newFTP = new ContainerOrderFocusTraversalPolicy();
            currentKFM.setDefaultFocusTraversalPolicy(newFTP);
            FocusTraversalPolicy defaultFTP = currentKFM.getDefaultFocusTraversalPolicy();
            System.out.println("defaultFTP: " + defaultFTP);

            JFrame f = new JFrame();

        /**
          * Note: this call doesn't affect already created components as they have
          * their policy initialized. Only new components will use this policy as
          * their default policy.
        **/

            FocusTraversalPolicy resultFTP = KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy();
            System.out.println("resultFTP: " + resultFTP);
            if (!resultFTP.equals(defaultFTP)) {
              System.out.println("FocusTraversalPolicy changed?!?!");
            }
          }
        }

        2. Compile and run using 6u13 on Solaris Sparc
        ----------------------------------------------
        % /jdk1.6.0_13/bin/javac FocusManagerTest.java
        % /jdk1.6.0_13/bin/java FocusManagerTest
        defaultFTP: java.awt.ContainerOrderFocusTraversalPolicy@5e5a50
        resultFTP: java.awt.ContainerOrderFocusTraversalPolicy@5e5a50
        %
        All fine.


        3. Compile and run using 6u13 on Windows
        ----------------------------------------
        F:\> c:\jdk1.6.0_13\bin\javac FocusManagerTest.java

        F:\> c:\jdk1.6.0_13\bin\java FocusManagerTest
        defaultFTP: java.awt.ContainerOrderFocusTraversalPolicy@1a758cb
        resultFTP: javax.swing.LayoutFocusTraversalPolicy@2e7263
        FocusTraversalPolicy changed?!?!

        F:\>


        4. Compile and run using 5u18 on Solaris Sparc
        ----------------------------------------------
        % /jdk1.5.0_18/bin/javac FocusManagerTest.java
        % /jdk1.5.0_18/bin/java FocusManagerTest
        defaultFTP: java.awt.ContainerOrderFocusTraversalPolicy@19106c7
        resultFTP: javax.swing.LayoutFocusTraversalPolicy@106082
        FocusTraversalPolicy changed?!?!
        %


        5. Compile and run using 5u18 on Windows
        ----------------------------------------
        F:\> c:\jdk1.5.0_18\bin\javac FocusManagerTest.java

        F:\> c:\jdk1.5.0_18\bin\java FocusManagerTest
        defaultFTP: java.awt.ContainerOrderFocusTraversalPolicy@35ce36
        resultFTP: javax.swing.LayoutFocusTraversalPolicy@1b67f74
        FocusTraversalPolicy changed?!?!

        F:\>

              alexp Alexander Potochkin (Inactive)
              thlenz Thomas Lenz (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: