I want to create a photo gallery in javafx using pop up window . But when I pass target image to a method to set content of a pop up window to that image primary image will be removed and pop up window will be open.Why?Please help me .Thank's ( Excuse my for my bad English!!! )
This is that snippet code .
final Popup popup = new Popup();
popup.getContent().add(image);
popup.setOnShown(new EventHandler<WindowEvent>(){
@Override
public void handle(WindowEvent t) {
image.setFitHeight(400);
image.setFitWidth(400);
}
});
popup.show(stage);
Your image is an ImageView, which is a Node. No node can appear in two scenes, or twice in the same scene graph.
To fix this, create a new ImageView, using the same image displayed in the current image (Images may be reused, even though ImageViews may not).