Run code:
@Override
public void start(Stage stage) throws Exception {
final Accordion acc = new Accordion();
final TitledPane pane1 = new TitledPane();
pane1.setGraphic(new Label("title 1\nLong text long text"));
pane1.setContent(new Button("Some button"));
acc.getPanes().addAll(pane1);
final TitledPane pane2 = new TitledPane();
pane2.setGraphic(new Label("title 1\nLong text long text"));
pane2.setContent(new Button("Some button"));
acc.getPanes().addAll(pane2);
final TitledPane pane3 = new TitledPane();
pane3.setGraphic(new Label("title 1\nLong text long text"));
pane3.setContent(new Button("Some button"));
acc.getPanes().addAll(pane3);
final ToggleButton visible = new ToggleButton("Visible");
pane2.visibleProperty().bindBidirectional(visible.selectedProperty());
VBox pane = new VBox();
pane.getChildren().addAll(visible, acc);
Scene scene = new Scene(pane, 300, 700);
stage.setScene(scene);
stage.show();
}
There is a toggle button, which switch visibility of the second Titled pane. when titled pane is invisible, there is just an empty space in accordion. I think, visible property should be tracked by accordion.
@Override
public void start(Stage stage) throws Exception {
final Accordion acc = new Accordion();
final TitledPane pane1 = new TitledPane();
pane1.setGraphic(new Label("title 1\nLong text long text"));
pane1.setContent(new Button("Some button"));
acc.getPanes().addAll(pane1);
final TitledPane pane2 = new TitledPane();
pane2.setGraphic(new Label("title 1\nLong text long text"));
pane2.setContent(new Button("Some button"));
acc.getPanes().addAll(pane2);
final TitledPane pane3 = new TitledPane();
pane3.setGraphic(new Label("title 1\nLong text long text"));
pane3.setContent(new Button("Some button"));
acc.getPanes().addAll(pane3);
final ToggleButton visible = new ToggleButton("Visible");
pane2.visibleProperty().bindBidirectional(visible.selectedProperty());
VBox pane = new VBox();
pane.getChildren().addAll(visible, acc);
Scene scene = new Scene(pane, 300, 700);
stage.setScene(scene);
stage.show();
}
There is a toggle button, which switch visibility of the second Titled pane. when titled pane is invisible, there is just an empty space in accordion. I think, visible property should be tracked by accordion.