Set LayoutX and LayoutY for a Control : Button « JavaFX « Java

Set LayoutX and LayoutY for a Control

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class Main extends Application {
    public static void main(String[] args) {
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World");
        Group root = new Group();
        Scene scene = new Scene(root, 300, 250);
        Button btn = new Button();
        btn.setText("Hello World");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent event) {
                System.out.println("Hello World");


Related examples in the same category

1.Add Click action listener to Button
2.Set Button Text
3.Button On Action
4.Set Button Graphic
5.Using CSS to change the look of a Button
6.Mouse in and out event for Button
7.Set Shadow effect for Button