I'm trying to style an FXML layout with CSS and it's picking up changes to font size but not font family, unless it's a 'generic' font-name. Am I doing something wrong? The minimal example below displays in the default font (Consolas is a valid font which I can load with Font.font("Consolas", 32.0f); ). In any case, if there's a problem with Consolas it should fallback to monospace, shouldn't it?
Thanks,
Peter
(System: Win XP 32-bit)
----
My CSS
Label {
-fx-font-size: 32pt;
-fx-font-family: 'Consolas', monospace;
}
----
My FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" >
<children>
<Label id="label" layoutX="80" layoutY="80" text="Test Text"/>
</children>
</AnchorPane>
----
My main class
package javafxapplication2;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class JavaFXApplication2 extends Application {
public static void main(String[] args) {
Application.launch(JavaFXApplication2.class, args);
}
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
final Scene scene = new Scene(root);
final String css = getClass().getResource("Sample.css").toExternalForm();
scene.getStylesheets().add(css);
stage.setScene(scene);
stage.show();
}
}
Edited by: 910144 on 25-Jan-2012 03:46
add code tags