On these days i am refactoring java swing code to javafx. And about some jpanels, i just refactored as JFXPanel and that JFXPanels` root is VBOX. the structure of JFXPanel is VBOX -> BorderPane -> TitledPane -> AnchorPane.
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="93.0" prefWidth="295.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<BorderPane prefHeight="259.0" prefWidth="309.0">
<top>
<TitledPane animated="false" prefHeight="93.0" prefWidth="297.0" style="-fx-background-color: #eeeeee;" text="Compensation Options" textFill="#1b75bc">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="295.0" prefWidth="267.0">
<children>
<Button fx:id="mResetCountButton" layoutX="25.0" layoutY="5.0" mnemonicParsing="false" text="Reset Counts" textAlignment="CENTER" />
<Button fx:id="plotStatsButton" layoutX="123.0" layoutY="5.0" mnemonicParsing="false" text="Stats Panel" textAlignment="CENTER" />
<Button fx:id="gateStatsButton" layoutX="208.0" layoutY="5.0" mnemonicParsing="false" text="Gate State" textAlignment="CENTER" />
<Button fx:id="mLoadMatrixButton" layoutX="28.0" layoutY="37.0" mnemonicParsing="false" text="Load Matrix" textAlignment="CENTER" />
<Button fx:id="viewCompMatrix" layoutX="119.0" layoutY="37.0" mnemonicParsing="false" text="View Matrix" textAlignment="CENTER" />
<Label fx:id="mJCompMatrixCombo" layoutX="208.0" layoutY="41.0" text="Matrix Name" />
</children>
</AnchorPane>
</content>
</TitledPane>
</top>
</BorderPane>
</children>
</VBox>
And now i want to make JFXPanels as Accordion. When i searched in google i just saw some code which use and when i make Accordion tag, i just can use TitledPane below tag. Is there any other way to make JFXPanels as Accordion reusing my code?...
And actually using Tag, i just can expand one titledPane at once. How can i make JavaFX application with Accordion which can expand many titledPanes at once?
I just tried as make titledPanesclicklistener and resizing VBox which is wrapping titledPane and titledpane
s size and some panes which in inside of titledpane.
such as
boolean titledPaneClicked = false;
TiteldPane.setOnAction((e)->{
if(titledPaneClicked){
TitledPane.setHeight(0);
Vbox.setHeight(0);
soemotherPanes.setHeight(0);
titledPaneClicked = !titledPaneClicked;
}else{
TitledPane.setHeight(previousSize);
Vbox.setHeight(previousSize);
soemotherPanes.setHeight(previousSize);
titledPaneClicked = !titledPaneClicked;
}
});
And it did not work. Plz help me :)
If your question is about how you can open close 2
TitledPane
s at once, you can do so programmatically, for example by using a button :Main.fxml (to make your code mcve always post the fxml name and imports)
And it controller:
Test it using :
If you want that opening / closing one
TitledPane
will open / close the other without using a button, remove the button from the fxml, and bindTitledPane.expandedProperty()
of the twoTitledPane
s in the controller: