-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
b03
-
x86
-
windows_2000
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2152888 | OpenJDK6 | Sergey Malenkov | P3 | Resolved | Fixed | b02 |
Name: sv35042 Date: 10/09/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
DefaultTreeCellRenderer icons and colors aren't updated in
updateUI() . So when one changes the look and feel and
calls SwingUtilities.updateComponentTreeUI(), the tree
icons and colors don't change.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I expected the icon to change to the windows icon but it
didn't.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.net.*;
class TreeBug3 {
public static void main(String[] args) throws Exception {
final JFrame frame = new JFrame();
JTree tree = new JTree(new String[]{"cell"});
tree.setCellRenderer(new DefaultTreeCellRenderer()
/*
// Here is the fix.
{
// should be called by the
DefaultTreeCellRenderer constructor
protected void init() {
setLeafIcon(UIManager.getIcon
("Tree.leafIcon"));
setClosedIcon(UIManager.getIcon
("Tree.closedIcon"));
setOpenIcon(UIManager.getIcon
("Tree.openIcon"));
setTextSelectionColor(UIManager.getColor
("Tree.selectionForeground"));
setTextNonSelectionColor
(UIManager.getColor("Tree.textForeground"));
setBackgroundSelectionColor
(UIManager.getColor("Tree.selectionBackground"));
setBackgroundNonSelectionColor
(UIManager.getColor("Tree.textBackground"));
setBorderSelectionColor
(UIManager.getColor("Tree.selectionBorderColor"));
// drawsFocusBorderAroundIcon is private
but should be protected
// Object value = UIManager.get
("Tree.drawsFocusBorderAroundIcon");
// drawsFocusBorderAroundIcon = (value !=
null && ((Boolean)value).
//
booleanValue());
}
public void updateUI() {
super.updateUI();
init();
}
}
*/
);
frame.getContentPane().add(tree,BorderLayout.CENTER);
frame.pack();
frame.show();
UIManager.setLookAndFeel
("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.invokeLater(new Runnable(){public void run(){
SwingUtilities.updateComponentTreeUI(frame);
}});
}
}
---------- END SOURCE ----------
(Review ID: 146024)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
DefaultTreeCellRenderer icons and colors aren't updated in
updateUI() . So when one changes the look and feel and
calls SwingUtilities.updateComponentTreeUI(), the tree
icons and colors don't change.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I expected the icon to change to the windows icon but it
didn't.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.net.*;
class TreeBug3 {
public static void main(String[] args) throws Exception {
final JFrame frame = new JFrame();
JTree tree = new JTree(new String[]{"cell"});
tree.setCellRenderer(new DefaultTreeCellRenderer()
/*
// Here is the fix.
{
// should be called by the
DefaultTreeCellRenderer constructor
protected void init() {
setLeafIcon(UIManager.getIcon
("Tree.leafIcon"));
setClosedIcon(UIManager.getIcon
("Tree.closedIcon"));
setOpenIcon(UIManager.getIcon
("Tree.openIcon"));
setTextSelectionColor(UIManager.getColor
("Tree.selectionForeground"));
setTextNonSelectionColor
(UIManager.getColor("Tree.textForeground"));
setBackgroundSelectionColor
(UIManager.getColor("Tree.selectionBackground"));
setBackgroundNonSelectionColor
(UIManager.getColor("Tree.textBackground"));
setBorderSelectionColor
(UIManager.getColor("Tree.selectionBorderColor"));
// drawsFocusBorderAroundIcon is private
but should be protected
// Object value = UIManager.get
("Tree.drawsFocusBorderAroundIcon");
// drawsFocusBorderAroundIcon = (value !=
null && ((Boolean)value).
//
booleanValue());
}
public void updateUI() {
super.updateUI();
init();
}
}
*/
);
frame.getContentPane().add(tree,BorderLayout.CENTER);
frame.pack();
frame.show();
UIManager.setLookAndFeel
("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.invokeLater(new Runnable(){public void run(){
SwingUtilities.updateComponentTreeUI(frame);
}});
}
}
---------- END SOURCE ----------
(Review ID: 146024)
======================================================================
- backported by
-
JDK-2152888 DefaultTreeCellRenderer icons and colors aren't updated in updateUI()
-
- Resolved
-
- relates to
-
JDK-6364555 Some SwingSet2 components do not dynamically update font antialiasing.
-
- Resolved
-