在这些天里,我正在将 java swing 代码重构为 javafx。关于一些 jpanel,我只是重构为 JFXPanel,而 JFXPanel 的根是 VBOX。JFXPanel 的结构是 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>
现在我想将 JFXPanels 制作为手风琴。当我在谷歌搜索时,我只看到了一些使用的代码,当我制作 Accordion 标签时,我只能在标签下面使用 TitledPane。有没有其他方法可以让 JFXPanels 作为 Accordion 重用我的代码?...
实际上使用 Tag,我可以一次展开一个 titledPane。如何使用 Accordion 制作 JavaFX 应用程序,它可以一次扩展多个 titledPanes?
我只是尝试让 titledPanesclicklistener and resizing VBox which is wrapping titledPane and titledpane
的大小和一些在 titledpane 内部的窗格。
如
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;
}
});
它没有用。请帮助我:)