スポンサーリンク
import java.io.File; import java.net.URL; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Fxml1 extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { URL file = new File("gui.fxml").toURI().toURL(); Parent root = FXMLLoader.load(file); stage.setTitle("FXML Test"); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } }
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.text.*?> <Pane prefWidth="350" prefHeight="212"> <children> <Label text="Hello, World!" layoutX="16" layoutY="32"> <font> <Font size="48.0" /> </font> </Label> </children> </Pane>
参考文献
http://java-buddy.blogspot.jp/2012/06/set-font-of-text-using-fxml-vs-javafx.html
http://www.ne.jp/asahi/hishidama/home/tech/java/fx/fxml/index.html