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

Stylesheet weird working mode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • fx1.3
    • None
    • javafx
    • Tested on desktop profile

      This run function causes the output in the attachment

      function run()
      {
          var group:Group = Group
          {
              content: Text{
                  textOrigin: TextOrigin.TOP;
                  styleClass: "LaneInfoText";
                  content: "MyText1";
              }

          }

          var stage = Stage
                  {
                      visible: true
                      width: 400;
                      height: 400;
                      style: StageStyle.UNDECORATED
                      title: "MainFrame";
                      scene: Scene{
                          stylesheets: ["file:/c:/javafx/javafx.css"]
                          content: bind group;
                          };
                  }
                   Timeline
                      {
                          repeatCount: 1
                          keyFrames :
                          [
                              KeyFrame
                              {
                                  time : 3s
                                  canSkip : true
                                  action: function():Void
                                      {
                                          insert Text{
                                              translateY: 50;
                                              textOrigin: TextOrigin.TOP;
                                              styleClass: "LaneInfoText";
                                              content: "MyText2";
                                          } into group.content;
                                      }

                              }
                          ]
                      }.play();

      }

      As far as I know the problem is that styles are not applied to nodes if they are created after the scene has been layout. There are two posible workarounds

      1) Really Slow: Refresh scene stylesheets
      2) Create temporal variables in a node that is created before the scene and bind then later when the new nodes are created

      I think that this is a bug, but in case it's not, at least needs to be well documented, I'm creating new nodes in some of my programs after laying out the scene, and this bug makes difficult working with css.

            dgrieve David Grieve
            anruizjfx Ander Ruiz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: