-
Bug
-
Resolution: Not an Issue
-
P4
-
5.0u18, 6u7, 6u12
-
x86, sparc
-
solaris_10, windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2177693 | 6-pool | Sean Coffey | P4 | Closed | Not an Issue |
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:\>
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:\>
- backported by
-
JDK-2177693 FocusTraversalPolicy is overwritten with default when a new JFrame object is created
- Closed
- duplicates
-
JDK-6863612 Java Web Start 6 does not preserve FocusTraversalPolicy on Windows
- Closed
-
JDK-2180733 Java Web Start 6 does not preserve FocusTraversalPolicy on Windows
- Closed
- relates to
-
JDK-6741526 KeyboardFocusManager.setDefaultFocusTraversalPolicy(FocusTraversalPolicy) affects created components
- Closed