简体   繁体   中英

java fx: combining texts and images(icons) in a sentence(Label)

Is it possible to embed an image within a label in between 2 words using Javafx. I know its possible to add image at the left, right and middle. Is it possible to embed within words? If not is there any other way to do it?

For Example I will have a page where I display the message:

Please select the flowers button (flowers image here) to go to flowers section

You can use TextFlow for that.

Like this:

Text text1 = new Text("word 1");
Text text2 = new Text("word 2");
ImageView imageView = new ImageView(
    new Image(getClass().getResource("smile.png").toExternalForm())
);
TextFlow textFlow = new TextFlow(text1, imageView, text2);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM