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

setStyle() overwrites setFont()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 7u6
    • 7u6
    • javafx
    • None

      Run the following snippet:
          @Override
          public void start(Stage stage) throws Exception {
              final Text text = new Text("Hello World");
              System.out.println(text.getFont()); //Prints System Regular 13
              text.setFont(new Font("Helvetica", 16));
              System.out.println(text.getFont()); //Prints Helvetica 16
              text.setStyle("-fx-font: 24pt serif;");
              System.out.println(text.getFont());//Prints Helvetica 16
              text.setFont(new Font("Monaco", 36));
              System.out.println(text.getFont());//Prints Monaco 36
              Platform.runLater(new Runnable() {
                  public void run() {
                      System.out.println(text.getFont());//Prints Serif 24, should be Monaco
                  }
              });

              VBox box = new VBox();
              box.getChildren().add(text);
              Scene scene = newa Scene(box, 300, 300);
              stage.setTitle("My JavaFX Application");
              stage.setScene(scene);
              stage.show();
          }

            dgrieve David Grieve
            fheidric Felipe Heidrich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: