0

How to put an image in PopOver header instead of text?

PopOver popover = new PopOver(); 
popover.setTitle("Controls");

I want to set an image not a text.

fabian
  • 80,457
  • 12
  • 86
  • 114

1 Answers1

0

Simply set a ImageView as contentNode

ImageView imageView = new ImageView("https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png");
PopOver popOver = new PopOver();
popOver.setContentNode(imageView);

If you want a header instead, you could simply use a VBox or a BorderPane or a similar suitable layout as contentNode...

fabian
  • 80,457
  • 12
  • 86
  • 114
  • @BoudjemaaBaali I've no idea what went wrong in your code, but the only 2 lines I added to sucessfully show the `PopOver` were `popOver.setArrowLocation(PopOver.ArrowLocation.LEFT_TOP);popOver.show(btn);` where `btn` is the button the `PopOver` is shown for. Note that it may take some time to download the image from the web, but you could also use an url to a image on your harddrive or some resource in a jar file... – fabian Feb 27 '17 at 16:43
  • thank you it's work ! ,but it's not what i was looking for, if i want to set string as title for the PopOver i will use popover.setTitle(""); but i want to use image instead of string ,they use label for the title but i don't now how to access this label to put image as backgrond for it ? – Boudjemaa Baali Feb 28 '17 at 18:31