Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Implementing breadcrumbs

ust2011Nov 4 2013 — edited Nov 6 2013

Hi,

I would like to implement a breadcrumbs bar using a ToolBar with a few Button items in it. The breadcrumbs should have the shape of an arrow like in the example shown here:

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.

Anyone here 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?

Thanks for your help,

Uwe

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2013
Added on Nov 4 2013
1 comment
1,099 views