package demo; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.Button; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.scene.text.TextAlignment; import javafx.stage.Stage; public class BugAppBorder extends Application { public static void main(String[] args) { launch(args); } Group root = new Group(); private void init(Stage primaryStage) { primaryStage.setScene(new Scene(root)); primaryStage.setHeight(250); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.show(); root.getChildren().add(drawNode()); } Pane borderPane; protected Pane baseFill(Pane pane) { pane.setPrefSize(180, 190); pane.setStyle("-fx-border-color: darkgray;"); return pane; } public Node drawNode() { borderPane = baseFill(new VBox()); final Canvas canvas = new Canvas(120, 120); GraphicsContext _gc = canvas.getGraphicsContext2D(); // _gc.setLineWidth(1); _gc.setFont(new Font(30)); // _gc.setTextAlign(TextAlignment.CENTER); _gc.strokeText("Text2", 50,60); borderPane.getChildren().addAll(canvas); return borderPane; } }