import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.Stage; import javafx.scene.text.TextAlignment; import javafx.scene.text.Font; import javafx.geometry.Pos; import javafx.geometry.Insets; import javafx.scene.layout.Border; import javafx.scene.layout.BorderStroke; import javafx.scene.layout.BorderStrokeStyle; import javafx.scene.layout.BorderWidths; import javafx.scene.paint.Color; import javafx.event.ActionEvent; import javafx.event.EventHandler; public class UIBspAction5 extends Application { Label label = null; @Override public void start(Stage stage) { VBox root = new VBox(22); root.setAlignment(Pos.CENTER); root.setFillWidth(true); Button bn = new Button("Klick mich") ; bn.setWrapText(true); bn.setTextAlignment(TextAlignment.CENTER); bn.setFont(new Font(22)); bn.setMaxWidth(Double.POSITIVE_INFINITY); bn.setPadding( new Insets(10) ); root.getChildren().add(bn); label = new Label("Hier ist Text") ; label.setWrapText(true); label.setTextAlignment(TextAlignment.CENTER); label.setFont(new Font("Courier New",22)); root.getChildren().add(label); bn.setOnAction( a->bnClick() ); Scene scene= new Scene(root, 250, 150); stage.setTitle("UIBspAction5"); stage.setScene(scene); stage.show(); } private void bnClick() { label.setText("Der Schalter wurde angeklickt"); } public static void main(String[] argv) { launch(argv); } }