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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 5.0u18, 6u7, 6u12
    • Fix Version/s: 7
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_10, windows_xp

      Backports

        Description

        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:\>

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: