openButton.setOnAction((final ActionEvent X) -> {
File newfile = fileChooser.showOpenDialog(stage);
Image userselectedimage = new Image(file.toURI().toString());
more code
newactionbutton.setOnAction((final ActionEvent X) ->{
* i need access to the user selected image variable here *
}
I need to access the variable userselectedimage (it is a image selected by the user for the background) in another button. is it possible since the scope is defined in that onclick action to access that variable in another button? I need it since its the users selected picture (it is a file that the user selects). I tried defining it outside of the method wiht a static variable but that didn't work either, so im out of ideas.
thanks.
Image userselectedimage = null;
openButton.setOnAction((final ActionEvent X) -> {
File newfile = fileChooser.showOpenDialog(stage);
userselectedimage = new Image(file.toURI().toString());
}
newactionbutton.setOnAction((final ActionEvent X) ->{
userselectedimage.doSomething();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.