Class Breadcrumbs

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class Breadcrumbs extends Container

A trail of the places above the current one, such as folders in a path, each of which goes back there when tapped.

Breadcrumbs crumbs = new Breadcrumbs("Home", "Documents", "Invoices");
crumbs.addActionListener(e -> Log.p("Back to " + crumbs.getSelectedItem()));

Tapping an item drops the items after it and tells the listeners; with setTruncateOnSelect(false) the trail is left as it is. The items use the UIID BreadcrumbItem, the last one BreadcrumbCurrent and the separators BreadcrumbSeparator. The trail wraps to more lines when it is too wide.

  • Constructor Details

    • Breadcrumbs

      public Breadcrumbs(String... path)

      A trail of the given items, the current place last.

      Parameters
      • path: the items, from the top
  • Method Details

    • setItems

      public void setItems(String... path)

      Replaces the items.

      Parameters
      • path: the items, from the top
    • push

      public void push(String item)

      Adds an item at the end, as the new current place.

      Parameters
      • item: the item
    • truncate

      public void truncate(int index)

      Drops the items after an index.

      Parameters
      • index: the index of the item that becomes the last one
    • getItems

      public String[] getItems()
      The items, from the top.
    • getSelectedIndex

      public int getSelectedIndex()
      The index of the item tapped last, or -1.
    • getSelectedItem

      public String getSelectedItem()
      The item tapped last, or null.
    • setSeparator

      public void setSeparator(String separator)

      Sets the text between items; "/" by default.

      Parameters
      • separator: the separator text
    • setTruncateOnSelect

      public void setTruncateOnSelect(boolean truncate)

      Sets whether tapping an item drops the items after it; true by default.

      Parameters
      • truncate: false to keep the trail
    • addActionListener

      public void addActionListener(ActionListener l)

      Adds a listener told when an item is tapped.

      Parameters
      • l: the listener
    • removeActionListener

      public void removeActionListener(ActionListener l)

      Removes a listener.

      Parameters
      • l: the listener
    • select

      public void select(int index)

      Selects an item as if the user tapped it.

      Parameters
      • index: the index of the item