我正在尝试用JavaFX编写一个使用FXML的Java程序。然而,我在布局管理方面遇到了问题。我想要在窗格之间切换,就像我习惯于在swing中使用CardLayout一样,但我似乎无法实现。
我用谷歌搜索了一下,没有找到任何答案。
在JavaFX中有没有CardLayout的等价物?如果是这样,你能给我举个例子吗?那会对我的晚上有很大的帮助!
以下是我的FXML代码
<AnchorPane id="anchorPane" prefHeight="324.0" prefWidth="530.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication2.SampleController">
<children>
<Pane fx:id="mainScreen" layoutX="6.0" prefHeight="324.0" prefWidth="518.0">
<children>
<Button layoutX="254.0" layoutY="37.0" mnemonicParsing="false" text="Button" />
</children>
</Pane>
<Pane fx:id="loginScreen" prefHeight="324.0" prefWidth="530.0">
<children>
<TextField id="password" fx:id="username" layoutX="142.0" layoutY="106.0" prefWidth="200.0" />
<TextField fx:id="password" layoutX="142.0" layoutY="140.0" prefWidth="200.0" />
<Label fx:id="label" layoutX="126.0" layoutY="120.0" minHeight="16.0" minWidth="69.0" />
<Button fx:id="button" layoutX="213.0" layoutY="196.0" onAction="#handleButtonAction" onKeyPressed="#handleButtonAction" text="Login" />
</children>
</Pane>
</children>
</AnchorPane>
https://stackoverflow.com/questions/16176701
复制相似问题