Custom Border for Callout Popup

Werner Lehmann lehmann at media-interactive.de
Mon May 7 12:32:16 PDT 2012


Hi,

I am creating a popup for a callout. The callout is basically a 
rectangle with a small arrow/tail on the top right corner and a single 
node for its content. That node may resize later and the callout has to 
adjust. http://i49.tinypic.com/21crux3.jpg

First I tried to do this with -fx-shape and an svg path but without 
luck: could not make this work, never saw that shape. Unfortunately I 
also did not find any example... I suppose even an SVG path border would 
not resize automatically when the content changes - otherwise this would 
be exactly what I need ;-)

Plan B is to use a Popup with a Path in the appropriate shape. This 
works but I am battling two things:

1. I have to know the popup content layout bounds before I can position 
the popup "right aligned". Currently solved by showing the popup 
offscreen (at -10000, 0) to get valid layoutBounds. Then I move it to 
the correct position. Is there a better way to get layoutBounds before 
showing a window?

2. When the content size changes, a similar problem arises: now I have 
to determine the new popup size, change the border Path to match the new 
size (PathElement binding might work here) and reposition the window. A 
resize animation would be nice, and some clipping will be needed also...

This is when I got an idea: is it possible to create and use a custom 
border class? Looks as if I could extend 
com.sun.javafx.scene.layout.region.Border... In this way I would get 
content clipping and resizing (position of arrow/tail must be adjusted) 
for free.

Any thoughts?

Thanks.
Werner



More information about the openjfx-dev mailing list