-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6u5
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Client VM (build 1.6.0_05-ea-b04, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Most other look and feels allow the developer to get the icon used to represent a directory or folder by using the code:
Icon folderIcon = UIManager.getIcon("FileView.directoryIcon");
This works on Metal, and the system look and feels on Windows, Mac, and Linux.
It does not work with Nimbus.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the look and feel to Nimbus and render a button with the icon value set to that returned from:
UIManager.getIcon("FileView.directoryIcon")
e.g.
JButton browseButton = new JButton(UIManager.getIcon("FileView.directoryIcon"));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The icon used for folders should be returned.
ACTUAL -
return value of null
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package nimbusbug;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
iconTest();
}
});
}
public static void iconTest() {
boolean showBug = true; // change to see the results with System L&F
try {
UIManager.setLookAndFeel(
showBug
? "sun.swing.plaf.nimbus.NimbusLookAndFeel"
: UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
JFrame frame = new JFrame("Nimbus Issues");
JButton browseButton = new JButton(UIManager.getIcon("FileView.directoryIcon"));
JPanel p = new JPanel();
p.add(new JLabel("This would make a greate 'browse' button:"));
p.add(browseButton);
frame.setContentPane(p);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Client VM (build 1.6.0_05-ea-b04, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Most other look and feels allow the developer to get the icon used to represent a directory or folder by using the code:
Icon folderIcon = UIManager.getIcon("FileView.directoryIcon");
This works on Metal, and the system look and feels on Windows, Mac, and Linux.
It does not work with Nimbus.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the look and feel to Nimbus and render a button with the icon value set to that returned from:
UIManager.getIcon("FileView.directoryIcon")
e.g.
JButton browseButton = new JButton(UIManager.getIcon("FileView.directoryIcon"));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The icon used for folders should be returned.
ACTUAL -
return value of null
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package nimbusbug;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
iconTest();
}
});
}
public static void iconTest() {
boolean showBug = true; // change to see the results with System L&F
try {
UIManager.setLookAndFeel(
showBug
? "sun.swing.plaf.nimbus.NimbusLookAndFeel"
: UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
JFrame frame = new JFrame("Nimbus Issues");
JButton browseButton = new JButton(UIManager.getIcon("FileView.directoryIcon"));
JPanel p = new JPanel();
p.add(new JLabel("This would make a greate 'browse' button:"));
p.add(browseButton);
frame.setContentPane(p);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6612359 Nimbus L&F: NetBeans 6.0 Beta 1 causes exceptions with 1.6.0_05-ea-b04
-
- Closed
-
- relates to
-
JDK-8027808 UIManager.getIcon(iconKey) does not return tree icons in GTK LAF
-
- Closed
-