Top Description Inners Fields Constructors Methods
org.controlsfx.control

public Class BreadCrumbBar<T>

extends ControlsFXControl
Class Inheritance
Imports
impl.org.controlsfx.skin.BreadCrumbBarSkin, javafx.beans.InvalidationListener, .Observable, javafx.beans.property.BooleanProperty, .ObjectProperty, .ObjectPropertyBase, .SimpleBooleanProperty, .SimpleObjectProperty, javafx.event.Event, .EventHandler, .EventType, javafx.scene.Node, javafx.scene.control.Button, .Skin, .TreeItem, javafx.scene.paint.Color, javafx.scene.shape.ArcTo, .ClosePath, .HLineTo, .LineTo, .MoveTo, .Path, javafx.util.Callback, java.util.UUID

Represents a bread crumb bar. This control is useful to visualize and navigate a hierarchical path structure, such as file systems.

Shown below is a screenshot of the BreadCrumbBar control:

Screenshot of BreadCrumbBar

Nested and Inner Type Summary

Modifier and TypeClass and Description

Field Summary

Modifier and TypeField and Description
private final BooleanProperty
private final ObjectProperty<Callback<TreeItem<T>, Button>>
private static final String
DEFAULT_STYLE_CLASS

* Stylesheet Handling * *

private final Callback<TreeItem<T>, Button>
defaultCrumbNodeFactory

Default crumb node factory.

private ObjectProperty<EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>>
private final ObjectProperty<TreeItem<T>>
private static final String

Constructor Summary

AccessConstructor and Description

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty

Returns:

a BooleanProperty
autoNavigationEnabledProperty
()

Enable or disable auto navigation (default is enabled).

public static <T> TreeItem<T>
buildTreeModel(T... crumbs)

Construct a tree model from the flat list which then can be set as selectedCrumb node to be shown

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObjectProperty<Callback<TreeItem<T>, Button>>

Returns:

an ObjectProperty of the CrumbFactory.
crumbFactoryProperty
()

Return an ObjectProperty of the CrumbFactory.

public final Callback<TreeItem<T>, Button>
getCrumbFactory()

Returns the cell factory that will be used to create BreadCrumbButton instances

public final EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>

Returns:

the EventHandler currently used when a user selects a crumb.
getOnCrumbAction
()

Return the EventHandler currently used when a user selects a crumb.

public final TreeItem<T>
getSelectedCrumb()

Get the current target path

public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final boolean

Returns:

whether auto-navigation is enabled.
isAutoNavigationEnabled
()

Return whether auto-navigation is enabled.

public final ObjectProperty<EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>>
onCrumbActionProperty()

Returns: an ObjectProperty representing the crumbAction EventHandler being used.

public final ObjectProperty<TreeItem<T>>
selectedCrumbProperty()

Represents the bottom-most path node (the node on the most-right side in terms of the bread crumb bar).

public final void
setAutoNavigationEnabled(boolean enabled)

Enable or disable auto navigation (default is enabled).

public final void
setCrumbFactory(Callback<TreeItem<T>, Button> value)

Sets the crumb factory to create (custom) BreadCrumbButton instances.

public final void
setOnCrumbAction(EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>> value)

Set a new EventHandler for when a user selects a crumb.

public final void
setSelectedCrumb(TreeItem<T> selectedCrumb)

Select one node in the BreadCrumbBar for being the bottom-most path node.

Inherited from org.controlsfx.control.ControlsFXControl:
getUserAgentStylesheet

Field Detail

autoNavigationback to summary
private final BooleanProperty autoNavigation
crumbFactoryback to summary
private final ObjectProperty<Callback<TreeItem<T>, Button>> crumbFactory
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

* Stylesheet Handling * *

defaultCrumbNodeFactoryback to summary
private final Callback<TreeItem<T>, Button> defaultCrumbNodeFactory

Default crumb node factory. This factory is used when no custom factory is specified by the user.

onCrumbActionback to summary
private ObjectProperty<EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>> onCrumbAction
selectedCrumbback to summary
private final ObjectProperty<TreeItem<T>> selectedCrumb
STYLE_CLASS_FIRSTback to summary
private static final String STYLE_CLASS_FIRST

Constructor Detail

Method Detail

autoNavigationEnabledPropertyback to summary
public final BooleanProperty autoNavigationEnabledProperty()

Enable or disable auto navigation (default is enabled). If auto navigation is enabled, it will automatically navigate to the crumb which was clicked by the user.

Returns:BooleanProperty

a BooleanProperty

buildTreeModelback to summary
public static <T> TreeItem<T> buildTreeModel(T... crumbs)

Construct a tree model from the flat list which then can be set as selectedCrumb node to be shown

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
crumbFactoryPropertyback to summary
public final ObjectProperty<Callback<TreeItem<T>, Button>> crumbFactoryProperty()

Return an ObjectProperty of the CrumbFactory.

Returns:ObjectProperty<Callback<TreeItem<T>, Button>>

an ObjectProperty of the CrumbFactory.

getCrumbFactoryback to summary
public final Callback<TreeItem<T>, Button> getCrumbFactory()

Returns the cell factory that will be used to create BreadCrumbButton instances

getOnCrumbActionback to summary
public final EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>> getOnCrumbAction()

Return the EventHandler currently used when a user selects a crumb.

Returns:EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>

the EventHandler currently used when a user selects a crumb.

getSelectedCrumbback to summary
public final TreeItem<T> getSelectedCrumb()

Get the current target path

getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
isAutoNavigationEnabledback to summary
public final boolean isAutoNavigationEnabled()

Return whether auto-navigation is enabled.

Returns:boolean

whether auto-navigation is enabled.

onCrumbActionPropertyback to summary
public final ObjectProperty<EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>> onCrumbActionProperty()
Returns:ObjectProperty<EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>>>

an ObjectProperty representing the crumbAction EventHandler being used.

selectedCrumbPropertyback to summary
public final ObjectProperty<TreeItem<T>> selectedCrumbProperty()

Represents the bottom-most path node (the node on the most-right side in terms of the bread crumb bar). The full path is then being constructed using getParent() of the tree-items.

Consider the following hierarchy: [Root] > [Folder] > [SubFolder] > [myfile.txt] To show the above bread crumb bar, you have to set the [myfile.txt] tree-node as selected crumb.

setAutoNavigationEnabledback to summary
public final void setAutoNavigationEnabled(boolean enabled)

Enable or disable auto navigation (default is enabled). If auto navigation is enabled, it will automatically navigate to the crumb which was clicked by the user.

setCrumbFactoryback to summary
public final void setCrumbFactory(Callback<TreeItem<T>, Button> value)

Sets the crumb factory to create (custom) BreadCrumbButton instances. null is not allowed and will result in a fall back to the default factory.

setOnCrumbActionback to summary
public final void setOnCrumbAction(EventHandler<BreadCrumbBar.BreadCrumbActionEvent<T>> value)

Set a new EventHandler for when a user selects a crumb.

setSelectedCrumbback to summary
public final void setSelectedCrumb(TreeItem<T> selectedCrumb)

Select one node in the BreadCrumbBar for being the bottom-most path node.