Custom Border for Callout Popup

Werner Lehmann lehmann at media-interactive.de
Wed May 9 02:28:37 PDT 2012


Hi Richard,

thanks for taking the time.

Actually, I was borrowing from the TooltipSkin already. In a previous 
version I had something similar to your code. That's when I discovered 
that I did not need to override anything in the root stackpane to layout 
the children or handle the min/pref/max width/height. It just works as 
is regarding the shape or resizing behaviour. Or, maybe I did not find 
the case where it does not work but I tested a few things.

Your skin works as good as mine I think - but alas does not handle my 
question: how to know the width of the popup before showing it, so that 
I can show it further to the left, and the callout hotspot is  considered.

Fortunately I was able to solve this meanwhile: an invalidation listener 
on the callout's widthProperty works for repositioning the  popup to the 
hotspot:

     callout.widthProperty().addListener(new InvalidationListener() {
       @Override
       public void invalidated(Observable paramObservable)
       {
         if (callout.getWidth() <= 0)
           return;

         Point2D hotspot = new Point2D(
           callout.getWidth() - 1.5 * ARROW_SIZE.getWidth(), 0);
         ...
         callout.setX(screenPoint.getX());
         callout.setY(screenPoint.getY());
       }
     });

Werner

On 09.05.2012 00:25, Richard Bair wrote:
> Hi Werner,
>
> Here is an updated Skin which works a bit better. What I added here I
> found in the TooltipSkin class, which you can peruse as it is open
> source. It uses the root node of the skin to do the layout of the
> background shape (which for simplicity I used a Rectangle, you could
> either use a path with known path elements that you reposition during
> layout or you can recreate the path elements each time).


More information about the openjfx-dev mailing list