I would like to ask is retrieving user profile image from UserClass and display the image on a button possible in JavaFX?
I have tried using setStyle to set the image but when I run the program it shows some error.
Here is my FXML controller file
private Button button1;
UserClass user = new UserClass();
public void initialize(URL location, ResourceBundle resources)
{
button.setStyle("-fx-background-image:'"+user.Photopath()+"'");
}
Here is my simplified UserClass class code
public class UserClass
{
private String photopath;
public String PhotoPath()
{
return "src/Pictures/womanprofile.png";
}
}
Here is the error log
WARNING: CSS Error parsing '*{-fx-background image:'src/Pictures/womanprofile.png'}:
You should check if your button size are too small. Hence, it only shows your background transparent image. Try enlarge your button and see how it solve your problem.