Code to reproduce the issue:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Test8 extends Application
{
public static void main(final String[] args)
{
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception
{
final VBox vbox = new VBox();
vbox.setPrefWidth(400);
vbox.setPrefHeight(400);
primaryStage.setScene(new Scene(vbox));
primaryStage.show();
final FlowPane flowPane1 = new FlowPane(new Button("Button 1"), new Button("Button 2"), new Button("Button 3"));
flowPane1.setMaxWidth(Double.MAX_VALUE);
flowPane1.setPrefWrapLength(-1);
final TitledPane titledPane1 = new TitledPane("Hello", flowPane1);
titledPane1.setMaxWidth(Double.MAX_VALUE);
final FlowPane flowPane2 = new FlowPane(new Button("Button 1"), new Button("Button 2"), new Button("Button 3"));
flowPane2.setMaxWidth(Double.MAX_VALUE);
flowPane2.setPrefWrapLength(400);
final TitledPane titledPane2 = new TitledPane("Hello", flowPane2);
titledPane2.setMaxWidth(Double.MAX_VALUE);
vbox.getChildren().addAll(titledPane1, titledPane2);
}
}
Try to change width of the window to see how buttons within flow panes do or do not wrap. Also try replacing the last line with
vbox.getChildren().addAll(flowPane1, flowPane2);
to see differences in behavior.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Test8 extends Application
{
public static void main(final String[] args)
{
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception
{
final VBox vbox = new VBox();
vbox.setPrefWidth(400);
vbox.setPrefHeight(400);
primaryStage.setScene(new Scene(vbox));
primaryStage.show();
final FlowPane flowPane1 = new FlowPane(new Button("Button 1"), new Button("Button 2"), new Button("Button 3"));
flowPane1.setMaxWidth(Double.MAX_VALUE);
flowPane1.setPrefWrapLength(-1);
final TitledPane titledPane1 = new TitledPane("Hello", flowPane1);
titledPane1.setMaxWidth(Double.MAX_VALUE);
final FlowPane flowPane2 = new FlowPane(new Button("Button 1"), new Button("Button 2"), new Button("Button 3"));
flowPane2.setMaxWidth(Double.MAX_VALUE);
flowPane2.setPrefWrapLength(400);
final TitledPane titledPane2 = new TitledPane("Hello", flowPane2);
titledPane2.setMaxWidth(Double.MAX_VALUE);
vbox.getChildren().addAll(titledPane1, titledPane2);
}
}
Try to change width of the window to see how buttons within flow panes do or do not wrap. Also try replacing the last line with
vbox.getChildren().addAll(flowPane1, flowPane2);
to see differences in behavior.