I am sorry if this is a dumb question it is my first time using javafx i am trying to learn. I am making a JavaFX project that involves updating the contents of a pane by clicking an item. The way it works is upon clicking an item, the data will be passed on the chosen item card. However, when i try to do this while it does update the labels and images it does not show it to the chosen item card. The codes below is the controller that updates the components in the chosen item card.
public void setChosenItem (Ardealya item) {
if (item == null) return;
Platform.runLater(() -> {
nameLabel.setText(item.getItemName());
priceLabel.setText("Php " + item.getPrice());
descriptionLabel.setText(item.getDescription());
// Ensure the image is updated correctly
Image image = new Image(getClass().getResourceAsStream(item.getImageSource()));
ImageChosen.setImage(image);
buyPanel.setVisible(true);
// Force the layout to update
buyPanel.requestLayout();
});
System.out.println("nName Label Updated: " + nameLabel.getText());
System.out.println("Price Label Updated: " + priceLabel.getText());
System.out.println("Description Label Updated: " + descriptionLabel.getText());
System.out.println("Image Updated: " + item.getImageSource());
}
this is a recording of my problem: https://drive.google.com/file/d/17KOrGrjkfDi3cBYF2YUKyRzyUu47VjtV/view?usp=sharing
I tried the relayout which forces the ui to refresh but it does not help me either.
Floppa Flopz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
7