我有一个JavaFx应用程序,具有两个视图,每个视图一个控制器。 不,我想在view1的VBbox中多次集成view2的锚定窗格。我不知道如何整合该视图。
我要集成的锚点(outgoingMessageView.fxml)
<AnchorPane fx:id="outgoingMessageAnchor" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.exxeta.mqttng.controller.OutgoingMessageViewController">
<children>
<BorderPane blendMode="SRC_OVER" focusTraversable="false" layoutX="486.0" layoutY="53.0" prefHeight="51.0" prefWidth="51.0">
<center>
<RadioButton mnemonicParsing="false" text="" />
</center>
</BorderPane>
<BorderPane blendMode="SRC_OVER" cache="true" cacheHint="DEFAULT" focusTraversable="false" layoutX="486.0" layoutY="0.0" prefHeight="51.0" prefWidth="51.0">
<center>
<RadioButton mnemonicParsing="false" text="" />
</center>
</BorderPane>
<Label layoutX="14.0" layoutY="11.0" text="/topic" />
<Label layoutX="14.0" layoutY="30.0" text="/topic" />
<Label layoutX="14.0" layoutY="48.0" text="550e8400-e29b-11d4-a716-446655440000" />
<TextField layoutX="14.0" layoutY="78.0" prefHeight="25.0" prefWidth="460.0" text="<?xml version="1.0" encoding="UTF-8"?><?import java.lang.*?><?import javafx.scene.*?><?import javafx.scene.control.*?><Group id="sb-clipboard" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"> <fx:define> <Label layoutX="14.0" layoutY="66.0" text="550e8400-e29b-11d4-a716-446655440000" /> </fx:define></Group>" />
<Label layoutX="365.0" layoutY="11.0" prefWidth="121.0" text="25-03-2019 15:46:00" />
<Label layoutX="379.0" layoutY="30.0" prefWidth="51.0" text="Retained" textAlignment="CENTER" />
<Label layoutX="446.0" layoutY="30.0" prefWidth="32.0" text="QoS2" textAlignment="CENTER" />
<Label layoutX="381.0" layoutY="51.0" prefWidth="97.0" text="Answer Expected" textAlignment="CENTER" />
<Separator layoutX="486.0" layoutY="3.0" minWidth="0.0" orientation="VERTICAL" prefHeight="98.0" prefWidth="0.0" />
</children>
</AnchorPane>
该视图的控制器:(OutgoingMessageViewController.java)
public class OutgoingMessageViewController {
@FXML
public AnchorPane outgoingMessageAnchor;
我要在其中集成锚定窗格的第一个视图的控制器:
AnchorPane newLoadedPane = new AnchorPane();
try {
newLoadedPane = FXMLLoader.load(getClass().getResource("../../../../../resources/com/exxeta/mqttng/controller/outgoingMessageView.fxml"));
} catch (IOException ex ){
}
outgoingVBox.getChildren().add(newLoadedPane);