-
Bug
-
Resolution: Fixed
-
P4
-
6u10
-
b11
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
After changing the Look & Feel from Metal to Nimbus and back to Metal, the Nimbus font continues to be used by a JFileChooser.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run code.
Close file chooser dialog.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect to see the same font both times the Metal L&F is used:
font javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
font javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]
ffont javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
ACTUAL -
font javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
font javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]
font javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class JFileChooserBug10 {
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception e) {
}
JFileChooser fc = new JFileChooser();
fc.showOpenDialog(null);
System.out.println("font " + fc.getFont());
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch (Exception e) {
}
SwingUtilities.updateComponentTreeUI(fc);
System.out.println("font " + fc.getFont());
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception e) {
}
SwingUtilities.updateComponentTreeUI(fc);
System.out.println("font " + fc.getFont());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Subclass JFileChooser and override updateUI() so that it nulls the font
before calling super.updateUI():
public void updateUI() {
setFont(null);
super.updateUI();
}
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
After changing the Look & Feel from Metal to Nimbus and back to Metal, the Nimbus font continues to be used by a JFileChooser.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run code.
Close file chooser dialog.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect to see the same font both times the Metal L&F is used:
font javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
font javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]
ffont javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
ACTUAL -
font javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
font javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]
font javax.swing.plaf.FontUIResource[family=SansSerif,name=sansserif,style=plain,size=12]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class JFileChooserBug10 {
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception e) {
}
JFileChooser fc = new JFileChooser();
fc.showOpenDialog(null);
System.out.println("font " + fc.getFont());
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch (Exception e) {
}
SwingUtilities.updateComponentTreeUI(fc);
System.out.println("font " + fc.getFont());
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception e) {
}
SwingUtilities.updateComponentTreeUI(fc);
System.out.println("font " + fc.getFont());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Subclass JFileChooser and override updateUI() so that it nulls the font
before calling super.updateUI():
public void updateUI() {
setFont(null);
super.updateUI();
}