我在一个fxml文件上有多个按钮.通过单击任何按钮,将显示在onAction
中定义的fxml表单.
问题是:
我是应该加载所有的表单,比如Foreach,当按钮单击正确的表单时,我只显示它,还是不需要?
如果我要加载所有的表格,我应该在initialize
函数中完成吗?
我是JavaFx
岁的新手,不知道最好的方法是什么?
EDIT:
例如,当btn1点击表单添加用户将显示,当点击btn2表单删除用户将显示,...
问题是:
我是否应该加载添加用户表单和删除用户表单,...当程序启动时,例如,当BTN1单击添加用户表单时,是否显示?
<BorderPane fx:controller="com.project.controller.eventcontroller" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<left>
<VBox prefHeight="400.0" prefWidth="110.0" style="-fx-background-color: #404040;" BorderPane.alignment="CENTER">
<children>
<Button fx:id="btn1" alignment="TOP_LEFT" mnemonicParsing="false" prefHeight="17.0" prefWidth="111.0" text="btn1" />
<Button fx:id="btn2" alignment="TOP_LEFT" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" prefHeight="17.0" prefWidth="111.0" text="btn2">
<VBox.margin>
<Insets top="12.0" />
</VBox.margin>
</Button>
<Button fx:id="btn3" alignment="TOP_LEFT" layoutX="10.0" layoutY="47.0" mnemonicParsing="false" prefHeight="17.0" prefWidth="111.0" text="btn3">
<VBox.margin>
<Insets top="12.0" />
</VBox.margin>
</Button>
<Button fx:id="btn4" alignment="TOP_LEFT" layoutX="10.0" layoutY="84.0" mnemonicParsing="false" prefHeight="17.0" prefWidth="111.0" text="btn4">
<VBox.margin>
<Insets top="12.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</left>
</BorderPane>
感谢所有人的帮助