Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to set a background image in javafx?

Liang123Oct 24 2013 — edited Oct 24 2013

Hi everyone,

I draw FXML GUI,it includes labels and ProgressBar,load it in JavaFX, this is a snippet.

root = FXMLLoader.load(getClass().getResource("StartMenuFXML.fxml"));

label1=(Label)root.lookup("#label");

label2=(Label)root.lookup("#label");

progressBar = (ProgressBar)root.lookup("#ProgressBar");

scene=new Scene(root,600,400);

stage.setTitle("Start Progress");

Progress p = new Progress();

p.start();

stage.setScene(scene);

stage.show();

I need to add a background picture in it, so I add the statements:

GridPane pane = new GridPane();

pane.setTitle("-fx-background-image: url('image1.jpg')");

and change: scene =new Scene(pane,600,400);

It can display the background picture, but I don't know how to display the labels and ProgressBar on the background picture.

Give me a good resolution please!

Thank you so much!

This post has been answered by James_D on Oct 24 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2013
Added on Oct 24 2013
2 comments
10,174 views