2 Replies Latest reply on May 16, 2013 3:33 PM by bjmueller

    Setting style to null does not reset font attributes - Bug or Feature?

      I call setStyle("-fx-font-weight: bold") with a label - the label's text is output in bold.
      Then I call setStyle(null) with the same label - expecting that now the label's font is back to the definition from the CSS.

      But: the label does not show a normal font now - it is still bold.
      I have to explicitly call setStyle("-fx-font-weight: normal") in order to bring it back to normal font.

      Is this a bug or a feature?
      If this is a bug, then I will post a Jira-message, but I am not yet 100% sure...

      My FX version is 2.2.

      Thanks + regards!

      Some example code:
      package ztest;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.SceneBuilder;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      public class Test_62_FontStyle 
          extends Application
          public static void main(String[] args)
          boolean m_bold = false;
          VBox m_vb = new VBox();
          Label m_la = new Label("Some text to be styled.");
          Button m_bu = new Button("Change");
          public void start(Stage primaryStage)
              final Scene scene = SceneBuilder.create()
              m_bu.addEventHandler(ActionEvent.ACTION,new EventHandler<ActionEvent>()
                  public void handle(ActionEvent paramT)
                      m_bold = !m_bold;
                      if (m_bold == true)
                          m_la.setStyle("-fx-font-weight: bold");
                          m_la.setStyle(null); // does not reset font!
      //                    m_la.setStyle("-fx-font-weight: normal"); // this works fine...