Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8095868

CSS for Region border is ignored when if background property is bound

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u60
    • Component/s: javafx
    • Labels:
    • Environment:

      JDK 8u20, NetBeans 8.0.2, Win7 x64

      Description

      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}

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: