Implementing Breadcrumbs in JavaFX

I’ve been struggling to implement a JavaFX breadcrumbs bar using a ToolBar with a few Button items in it. The breadcrumbs should have the shape of an arrow as in the example shown in Loop81’s blog post:

http://www.loop81.com/2011/11/javafx-2-breadcrumbs-and-styling.html

The breadcrumbs bar in the Ensemble application uses the same approach. What I don’t like about this implementation is the use of rather sophisticated CSS rules in combination with static images.

As another approach, I tried to define an arrow-shaped SVG path (using the -fx-shape CSS rule) for the breadcrumb buttons, but I encountered scaling issues. The width of the shape must depend on the width of the text displayed in the button, which could not be achieved using CSS.

So I defined the shape in Java code and used it to set the button’s clip. The width of the shape was computed dynamically based on the button’s text plus two magic numbers for the correct scaling of the shape. This worked nicely, but came with the burden of those two magic numbers that worked well only for the particular font I used.

In yet another attempt, I implemented a breadcrumbs bar in which every breadcrumb is represented by three buttons: one for the left-hand part of the arrow, one for the central part (showing the text), and one for the right-hand part. This allowed me to work with fixed-width shapes on the left and on the right plus a regular-shaped (rectangular) button in the middle. The obvious drawback was the management of all the extra buttons including the correct update of hover effects for the outer buttons when the mouse was over the inner button, and vice versa.

I don’t think there a JavaFX library out there that provides the functionality I need, so is there anyone with experience in implementing a breadcrumbs bar? Any thoughts or recommendations? Are there solutions that do not come with any of the drawbacks mentioned above?

Any help will be much appreciated.

Update (2013-11-06):

Andy Till suggested an implementation that won my heart: bind the x property of the horizontal lines in the arrow shape to the button’s width. Since the button’s width gets updated to fit the text, the shape will always have the correct width. No need for magic numbers. Thanks, Andy!

And this is what my breadcrumbs bar looks like now:

breadcrumbs