Answer the question
In order to leave comments, you need to log in
JavaFx how to get parameters from controller?
Good
There is a VBox, the user adds a Node containing an Image to it. Those. children is dynamically populated in VBox. At some point, I need to know how to get data from the control of these Node, how to do it?
What I'm doing is looping through the children of the VBox, getting links to the children, but how do I get data from the controller? (Node contains an image, I need to get the path to it)
example but doesn't work
for (int i = 0; view.getVBox_image().getChildren().size() > i; ++i) {
V_ItemImageIcon itemImage = (V_ItemImageIcon) view.getVBox_image().getChildren().get(i);
image.add(itemImage.getFileImage());
}
Error:(174, 101) java: incompatible types: javafx.scene.Node cannot be converted to com.view.vItemImageIcon.v.V_ItemImageIcon
Answer the question
In order to leave comments, you need to log in
Neonoviiwolf
tried to give in xmlfx:id
in the code to create a variable in the controller class
@FXML
private Image dialogImage;
if (dialogImage != null) {
System.err.println(String.format("The image url: %s",
dialogImage.impl_getUrl()));
}
<Label fx:id="dialogImageLabel">
<graphic>
<ImageView fx:id="dialogImageView" fitHeight="128" fitWidth="128" pickOnBounds="true" preserveRatio="true">
<image>
<Image fx:id="dialogImage" url="@watchglass.png"/>
</image>
</ImageView>
</graphic>
</Label>
for (int i = 0; i != dialogImageLabel.getChildrenUnmodifiable()
.size(); i++) {
Node itemNode = dialogImageLabel.getChildrenUnmodifiable().get(i);
if (itemNode.getClass().getName().equals("javafx.scene.image.ImageView")) {
ImageView imageView = (ImageView) itemNode;
System.err.println(String.format("The child image url: %s",
imageView.getImage().impl_getUrl()));
}
}
the sameThe child image url: file:/<путь к проекту>/src/main/resources/картина.png
not quite the same, probably unsuccessfully explained
VBox - a container, the client adds Pane to it, which in turn contains some objects, including image. I need to somehow get data from the Pane controller, more precisely a link to an Image
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question