Class NavBarItem

All Implemented Interfaces:
Animatable<ListItem>, CanDrop<ListItem>, Clickable<ListItem>, Draggable<ListItem>, Focusable<ListItem>, HandleHotKey<ListItem>, HandleMouseEvents<ListItem>, Scrollable<ListItem>, Touchable<ListItem>

public class NavBarItem extends ListItem
Menu item component for NavBar.

The component is not a standalone component, it is only displayed in the NavBar.

The menu item component represents a menu item. You can add further menu items (sub-menu items) to a menu item, these will drop down from the main item. You can add an icon to main menu items. This is displayed before the menu item text. Sub-menu items do not display an icon.

The component cannot be permanently created. It can only be instantiated using the NavBar.createItem method. Such components are created if you add a Startup menu item to the NavBar component using the NavBar.addMenu method. You can add more menus to the NavBar component, each one individually labeled.

You can specify a marker for each menu item. The specified marker is displayed on the right side of the menu item. You can add a text to the marker, thereby labeling the menu item. Also, you can set the marker color by specifying its type.

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • NavBarItem

      protected NavBarItem(String name, boolean header)
      Parameters:
      name - The menu item name (required for the noram menu item)
      header - If set true create a menu header item, otherwise create normal menu item
      Throws:
      NullPointerException - If create a normal menu item, vagy specified name is null
  • Method Details

    • addNavigationEventHandler

      protected NavBarItem addNavigationEventHandler(NavigationEventHandler handler)
      Parameters:
      handler - The navigatin event handler implementation
      Returns:
      The menu item component
    • setHotKey

      protected NavBarItem setHotKey(int hotKey)
      Parameters:
      hotKey - The hot key
      Returns:
      The menu item component
    • getName

      public final String getName()
      Gets a menu item name.
      Overrides:
      getName in class Component<ListItem>
      Returns:
      Menu item name
    • setIcon

      public NavBarItem setIcon(Icon icon)
      Sets the icon for a menu item.
      Parameters:
      icon - Menu item icon If null is set, no icon is displayed. Available icons are listed in the enum Icon.
      Returns:
      Menu item component
    • getIcon

      public Icon getIcon()
      Gets the icon assigned to the menu item.
      Returns:
      Menu item icon or null if no icon is specified
    • setTitle

      public NavBarItem setTitle(String title)
      Sets the title for a menu item.
      Parameters:
      title - Menu item title If null or an empty string is specified, no title is displayed.
      Returns:
      Menu item component
    • getTitle

      public String getTitle()
      Gets the title for a menu item.
      Returns:
      Menu item title or null if no title has been specified
    • setMarkerText

      public NavBarItem setMarkerText(String markerText)
      Adds a default (grey) marker to the menu item.
      Parameters:
      markerText - Marker text
      Returns:
      Menu item component
    • setMarker

      public NavBarItem setMarker(String markerText, BadgeType type)
      Shows a marker on the menu item (marker type specified).
      Parameters:
      markerText - Marker text If null is set, no marker is displayed.
      type - Marker type (color) If null is set, the marker type is not modified. A list of types to be used is contained in the BadgeType enum.
      Returns:
      Menu item component
    • getMarkerText

      public String getMarkerText()
      Gets the marker text assigned to a menu item.
      Returns:
      Marker text or null if there is no marker assigned to the menu item or no text has been specified
    • getMarker

      public Span getMarker()
      Gets the marker assigned to a menu item.
      Returns:
      Marker or null if there is no marker assigned to the menu item
    • addItem

      public NavBarItem addItem(String name, String title)
      Adds a new sub-menu item to the component.
      Parameters:
      name - Sub menu item name
      title - Menu item title If null is specified, an empty menu item is displayed.
      Returns:
      New menu item
      Throws:
      NullPointerException - Thrown if the specified name is null
    • findItemByName

      public NavBarItem findItemByName(String name)
      Gets a sub-menu item of a menu item by its name.
      Parameters:
      name - The menu item name searched for
      Returns:
      Sub-menu item corresponding to the specified name or null if the specified name is null or there is no sub-menu item by that name
    • removeItemByName

      public NavBarItem removeItemByName(String name)
      Removes a sub menu item by its name.
      Parameters:
      name - Sub menu item name to be removed
      Returns:
      Menu item component