To add Label to BorderPane center in JavaFX window
// Use a BorderPane for the root node. BorderPane rootNode = new BorderPane(); // Create a scene. Scene myScene = new Scene(rootNode, 300, 300); rootNode.setCenter(response);
Full source
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { //Create a label that will report the selection. private Label response = new Label("Menu Demo"); public static void main(String[] args) { launch(args);/*from w w w . j a v a 2 s . co m*/ } public void start(Stage myStage) { myStage.setTitle("Menus from java2s.com"); // Use a BorderPane for the root node. BorderPane rootNode = new BorderPane(); Scene myScene = new Scene(rootNode, 300, 300); myStage.setScene(myScene); rootNode.setCenter(response); myStage.show(); } }