Reputation: 10802
So, this is the code, that I have now:
SplitPane sp = new SplitPane();
final StackPane sp1 = new StackPane();
final Accordion accordion = new Accordion ();
TitledPane tp1 = new TitledPane();
tp1.setText("First");
TitledPane tp2 = new TitledPane();
tp2.setText("Second");
TitledPane tp3 = new TitledPane();
tp3.setText("Third");
accordion.getPanes().add(tp1);
accordion.getPanes().add(tp2);
accordion.getPanes().add(tp3);
sp1.getChildren().add(accordion);
final StackPane sp2 = new StackPane();
sp.getItems().addAll( sp1 , sp2 );
double height = Screen.getPrimary().getVisualBounds().getHeight();
double width = Screen.getPrimary().getVisualBounds().getWidth();
Scene scene = new Scene( sp );
primaryStage.setScene( scene );
primaryStage.setMaximized( true );
primaryStage.setMinHeight( height );
primaryStage.setMinWidth( width );
primaryStage.show();
sp.setDividerPositions(0.3);
As you can see, I have an accordion with three TitledPane
s inside. What I want is that when a user clicks on a TitledPaned, then it should expand to the full height of its parent object (accordion in this case). But I do not know how to do that. This is what I have now:
Please, pay attention, that on the above picture even though the first panel is activated, it is not expanded. An this is what I want:
(I created the last picture manually). Thanks!
Upvotes: 0
Views: 1946
Reputation: 2961
I think, you need to call setContent()
method.
Example:
TextField firstNameFld = new TextField();
firstNameFld.setPrefColumnCount(8);
TextField lastNameFld = new TextField();
lastNameFld.setPrefColumnCount(8);
GridPane grid = new GridPane();
grid.addRow(0, new Label("First Name:"), firstNameFld);
grid.addRow(1, new Label("Last Name:"), lastNameFld);
tp1.setContent(grid);
tp2.setContent(new Label("tp2............."));
tp3.setContent(new Label("tp3.............."));
Upvotes: 1