I created an AnchorPane. I then added CSS for manipulating the AnchorPane's border (e.g. -fx-border-width, -fx-border-color, etc.). This worked as expected. I then uni-directionally bound the background property of the AnchorPane in my code. The CSS for the border is no longer working.
I spent some time tracking down why this would occur. It appears to be caused by a typo in javafx.scene.layout.Region. In the nested StyleableProperties class there is a static CssMetaData variable named BORDER. The isSettable(Region) method checks if the background property has been bound. I believe it should be checking if the border property is bound.
I've experience this in the 8u20 JDK. However, I've looked briefly at the code for 8u40 and 9. The bug appears present there as well.
Relevant code:
{code:title=Region.java|borderStyle=solid}
package javafx.scene.layout;
public class Region extends Parent {
...
private static class StyleableProperties {
...
private static final CssMetaData<Region,Border> BORDER =
new CssMetaData<Region,Border>("-fx-region-border",
...
@Override public boolean isSettable(Region node) {
return !node.background.isBound();
}
{code}
I believe it should be changed to this instead:
{code:title=Region.java|borderStyle=solid}
package javafx.scene.layout;
public class Region extends Parent {
...
private static class StyleableProperties {
...
private static final CssMetaData<Region,Border> BORDER =
new CssMetaData<Region,Border>("-fx-region-border",
...
@Override public boolean isSettable(Region node) {
return !node.border.isBound();
}
{code}
I spent some time tracking down why this would occur. It appears to be caused by a typo in javafx.scene.layout.Region. In the nested StyleableProperties class there is a static CssMetaData variable named BORDER. The isSettable(Region) method checks if the background property has been bound. I believe it should be checking if the border property is bound.
I've experience this in the 8u20 JDK. However, I've looked briefly at the code for 8u40 and 9. The bug appears present there as well.
Relevant code:
{code:title=Region.java|borderStyle=solid}
package javafx.scene.layout;
public class Region extends Parent {
...
private static class StyleableProperties {
...
private static final CssMetaData<Region,Border> BORDER =
new CssMetaData<Region,Border>("-fx-region-border",
...
@Override public boolean isSettable(Region node) {
return !node.background.isBound();
}
{code}
I believe it should be changed to this instead:
{code:title=Region.java|borderStyle=solid}
package javafx.scene.layout;
public class Region extends Parent {
...
private static class StyleableProperties {
...
private static final CssMetaData<Region,Border> BORDER =
new CssMetaData<Region,Border>("-fx-region-border",
...
@Override public boolean isSettable(Region node) {
return !node.border.isBound();
}
{code}