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 UIBspAction3 extends Application { @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 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(new EventHandler(){ @Override public void handle(ActionEvent event) { label.setText("Der Schalter wurde angeklickt"); } }); Scene scene= new Scene(root, 250, 150); stage.setTitle("UIBspAction3"); stage.setScene(scene); stage.show(); } public static void main(String[] argv) { launch(argv); } }