First post by a newbi - please be gentle :) I'm currently writing a database of vehicles in a museum. I am able to save it as XML. However I recently tried adding images of the vehicles into the database via a dialogStage which worked well until I tried to save as XML. Now I get the error that it can't save and all I have is an empty XML file. I am using FileChooser to upload the image. The TextArea fileLocation is used to display the location that the image has been uploaded from. The only way I can see around this is to scrap using .toURI and instead upload the images to a designated folder automatically without having to use a save dialog so that the XML doesn't have to try saving the images which is what I believe is breaking it). I have spent days browsing here and other sites and trying various methods but to no avail. I include the FileChooser method below. Can anyone help me at all please? Any alternative solutions are equally welcome. Many Thanks in advance.
@FXML
private TextArea fileLocation;
private Image image;
private File file;
private FileChooser fileChooser;
{
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select Image");
file = fileChooser.showOpenDialog(dialogStage);
if(file != null)
{
fileLocation.setText(file.getAbsolutePath());
image = new Image(file.toURI().toString(), 140, 212, true, true);
imageView.setImage(image);
imageView.setFitWidth(140);
imageView.setFitWidth(212);
imageView.setPreserveRatio(true);
}
}