import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * * @author Alexander Kouznetsov */ public class WordWrapTest extends Application{ @Override public void start(Stage primaryStage) { final Label label1 = new Label("This is very long label1 This is very long label This is very long label"); label1.setWrapText(true); label1.setStyle("-fx-border-color: red;"); Button button1 = new Button("Button1"); final Label label2 = new Label("This is very long label2 This is very long label This is very long label"); label2.setWrapText(true); label2.setStyle("-fx-border-color: blue;"); Button button2 = new Button("Button2"); final GridPane pane2 = new GridPane(); GridPane.setConstraints(button2, 0, 1); pane2.getChildren().setAll(label2, button2); VBox pane = new VBox(); pane.getChildren().setAll(label1, button1, pane2); Scene scene = new Scene(pane, 500, 500); primaryStage.setScene(scene); primaryStage.setVisible(true); } public static void main(String[] args) { launch(args); } }