/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package demo; import java.io.IOException; import javafx.application.Application; import static javafx.application.Application.launch; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.stage.Stage; /** * * @author paru */ import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.FlowPane; import javafx.scene.layout.Pane; import javafx.scene.text.Font; public class ButtonHoverContract2 extends Application { @Override public void start(Stage stage) throws IOException { Group grp = new Group(); final VBox outer = new VBox(10); final Pane pane = new Pane(); final FlowPane fp = new FlowPane(); Button button = new Button("VBox"); outer.getChildren().addAll(fp, pane); fp.getChildren().add(button); final VBox vbox = new VBox(); final VBox inner = new VBox(); vbox.getChildren().addAll(new Label("Defaults"), inner); Button b1 = new Button("btn"); vbox.setTranslateX(200); vbox.setTranslateY(200); b1.setFont(new Font(24)); b1.setMaxWidth(85); b1.setMaxHeight(85); inner.getChildren().add(b1); vbox.setPrefSize(80, 240); vbox.setStyle("-fx-border-color: red;"); //button.setOnAction(new EventHandler() { // @Override // public void handle(ActionEvent t) { pane.getChildren().add(vbox); // } //}); grp.getChildren().addAll(outer); Scene scene = new Scene(grp, 800, 800); setCustomFont(scene); stage.setScene(scene); stage.show(); } public static void main(String args[]) { launch(args); } public static void setCustomFont(Scene scene) throws IOException { // custom_font.css file content should be: // .root , .table-header { -fx-font: 12 Arial; } String cssFontUrl = ButtonHoverContract2.class.getResource("custom_font.css").toExternalForm(); scene.getStylesheets().add(cssFontUrl); } }