place an image to Label in javaFx

1

I would like to put an image at label of the Fx library. I have tried but I can not find any method that has this function.

Label label= new Label();
label.setBackgraund();
    
asked by Carlos Alberto Argote Quintero 06.06.2017 в 16:36
source

1 answer

1

Right now I can not give you an example using ControlsFX.

But you can also do it without needing this library in the following way:

Image image = new Image(getClass().getResourceAsStream("tuImagen.jpg")); 
Label myLabel = new Label("Texto Label"); 
myLabel.setGraphic(new ImageView(image));

Of course the image file must be in the folder of your project.

You can see more details in the Java documentation .

    
answered by 07.06.2017 / 03:15
source