JavaFX 2.2 -fx:include - wie Zugriff auf parent-controller vom Kindes-controller
Hatte ich code von stackoverflow auf "access-Kind-controller von der übergeordneten Steuerung" als unten.
ParentController.java
public class ParentController implements Initializable{
@FXML private childController childController;
@Override
public void initialize(URL location, ResourceBundle resources) {
childController.sessionLabel.setText("Real blabla");
System.out.println("sessionLabel= " + childController.sessionLabel.getText());
}
}
childController.java
public class childController implements Initializable{
@FXML public Label sessionLabel;
@Override
public void initialize(URL location, ResourceBundle resources) {
}
}
Kind.fxml
<AnchorPane maxHeight="20.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml" fx:controller="childController">
<children>
<HBox id="hbox_top" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<Label fx:id="sessionLabel" prefHeight="20.0" text="" />
</HBox>
</children>
</AnchorPane>
Eltern.fxml
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml" fx:controller="ParentController">
<children>
<fx:include fx:id="child" source="child.fxml"/>
<Label fx:id="lebelInParent" prefHeight="20.0" text="" />
</children>
</AnchorPane>
Meine Anfrage - ich möchte Zugriff lebelInParent der Eltern.fxml aus childController.java. Jede Hilfe ist appriciated.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Habe ich wie folgt -
Kind.fxml
Erklärung - es lädt Eltern.fxml und wenn ich auf sessionLabel, ruft mClicked Methode der childController und Kind.getParent().lookup, Suche nach Id-und return-Knoten.