-
Bug
-
Resolution: Fixed
-
P3
-
7u45, 8, 9
-
b08
-
windows
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
I've found a couple of errors in the method: javax.swing.tree.DefaultTreeCellRenderer.updateUI().
(1) There is a typo on one of the properties:
if (!inited || (getOpenIcon() instanceof UIManager)) {
That should be:
if (!inited || (getOpenIcon() instanceof UIResource)) {
(2) This part of the method causes incompatibilities between themes, because the border is not removed if the margins are null:
Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
if (margins != null) {
setBorder(new EmptyBorder(margins.top, margins.left,
margins.bottom, margins.right));
}
E.g., the Nimbus L&F has the "Tree.rendererMargins" property, which sets the border. After switching to the Windows L&F, which does not have the property, the Nimbus border persists, upsetting the appearance of the tree. This code also doesn't honor any user-set border. Suggested fix (not tested):
if (!inited || (getBorder() instanceof UIResource)) {
Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
if (margins != null) {
setBorder(new javax.swing.plaf.BorderUIResource.EmptyBorderUIResource(margins));
} else {
setBorder(new javax.swing.plaf.BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0));
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
I've found a couple of errors in the method: javax.swing.tree.DefaultTreeCellRenderer.updateUI().
(1) There is a typo on one of the properties:
if (!inited || (getOpenIcon() instanceof UIManager)) {
That should be:
if (!inited || (getOpenIcon() instanceof UIResource)) {
(2) This part of the method causes incompatibilities between themes, because the border is not removed if the margins are null:
Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
if (margins != null) {
setBorder(new EmptyBorder(margins.top, margins.left,
margins.bottom, margins.right));
}
E.g., the Nimbus L&F has the "Tree.rendererMargins" property, which sets the border. After switching to the Windows L&F, which does not have the property, the Nimbus border persists, upsetting the appearance of the tree. This code also doesn't honor any user-set border. Suggested fix (not tested):
if (!inited || (getBorder() instanceof UIResource)) {
Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
if (margins != null) {
setBorder(new javax.swing.plaf.BorderUIResource.EmptyBorderUIResource(margins));
} else {
setBorder(new javax.swing.plaf.BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0));
}
}
REPRODUCIBILITY :
This bug can be reproduced always.