java - JavaFx: How to install a Tooltip on ImageView -


i tried this:

public void addtargetcard(missioncard mcard) {     int card = mcard.getid();     leftside.getchildren().removeall(targetcardbox);     image image = new image(             mainapp.class.getresourceasstream("images/target" + card                     + ".png"));     imageview imageview = new imageview();     imageview.setimage(image);     imageview.setfitheight(81);     imageview.setfitwidth(108);     imageview.setpreserveratio(true);     imageview.setpickonbounds(true);     tooltip.install(imageview, new tooltip(inttocity(mcard.getstart())             + " - " + inttocity(mcard.getfinish())));     targetcardbox.getchildren().add(imageview);     leftside.getchildren().add(targetcardbox); } 

can explain me why tooltip doesn't work - got no idea did wrong. (it's first time use tooltips's)


somebody else told me imageview doesnt work tooltips , gave me workaround - have again no tooltip when move mouse on label

    public void addtargetcard(missioncard mcard) {     int card = mcard.getid();     leftside.getchildren().removeall(targetcardbox);     image image = new image(             mainapp.class.getresourceasstream("images/target" + card                     + ".png"));     imageview imageview = new imageview();     imageview.setimage(image);     imageview.setfitheight(81);     imageview.setfitwidth(108);     imageview.setpreserveratio(true);     imageview.setpickonbounds(true);     label label = new label();     label.setcontentdisplay(contentdisplay.graphic_only);     label.setgraphic(imageview);     label.settooltip(new tooltip(inttocity(mcard.getstart()) + " - "             + inttocity(mcard.getfinish())));     targetcardbox.getchildren().add(label);     leftside.getchildren().add(targetcardbox); } 

installing tooltip image view working. try new sample javafx project , see it. when doubt functionality of used api (javafx in case) try isolate doubted use case new fresh environment/project , observe closely.

p.s. why removing targetcardbox leftside , adding again afterwards.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -