Class SubmenuPiece

java.lang.Object
bibliothek.gui.dock.support.menu.MenuPiece
bibliothek.gui.dock.facile.menu.SubmenuPiece

public class SubmenuPiece extends MenuPiece
A MenuPiece which consists only of one JMenu. There is a new subtree attached to this SubmenuPiece.
Author:
Benjamin Sigg
  • Constructor Details

    • SubmenuPiece

      public SubmenuPiece()
      Creates a new submenu-piece, using a normal JMenu to inserts its content.
    • SubmenuPiece

      public SubmenuPiece(String text, boolean disableWhenEmpty, MenuPiece... pieces)
      Creates a new submenu-piece, using a normal JMenu.
      Parameters:
      text - the text of the menu
      disableWhenEmpty - whether to disable the menu when it is empty
      pieces - the elements of this piece
    • SubmenuPiece

      public SubmenuPiece(JMenu menu)
      Creates a new submenu-piece.
      Parameters:
      menu - the menu into which this piece will insert its content
  • Method Details

    • bind

      public void bind()
      Description copied from class: MenuPiece
      This method is called if there is a possibility for the user to see this menu. The menu should register listeners, update its text etc. to be ready for that event. This method must never be called twice in a row.
      Overrides:
      bind in class MenuPiece
      See Also:
    • unbind

      public void unbind()
      Description copied from class: MenuPiece
      This method is called if the user has no longer any possibility to see this menu. The menu should unregister its listeners. This method must never be called twice in a row.
      Overrides:
      unbind in class MenuPiece
      See Also:
    • fill

      public void fill(List<Component> items)
      Description copied from class: MenuPiece
      Inserts all items of this piece into items.
      Specified by:
      fill in class MenuPiece
      Parameters:
      items - the list which has to be filled in the same order as the items will appear on the menu
    • getItemCount

      public int getItemCount()
      Description copied from class: MenuPiece
      Gets the number of items this MenuPiece added to its menu.
      Specified by:
      getItemCount in class MenuPiece
      Returns:
      the number of items
    • setDisableWhenEmpty

      public void setDisableWhenEmpty(boolean disableWhenEmpty)
      Disables the menu if there are no items in the menu.
      Parameters:
      disableWhenEmpty - true if the menu should be disabled when empty
    • isDisableWhenEmpty

      public boolean isDisableWhenEmpty()
      Whether to disable the menu when it is empty or not.
      Returns:
      true if the menu gets disabled
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets whether the submenu can be enabled. The actual state of the menu also depends on isDisableWhenEmpty().
      Parameters:
      enabled - whether the submenu can be enabled
    • isEnabled

      public boolean isEnabled()
      Tells whether the submenu could be enabled. The actual state of the menu also depends on isDisableWhenEmpty()
      Returns:
      whether the menu could be enabled
    • getMenu

      public JMenu getMenu()
      Description copied from class: MenuPiece
      Gets the menu into which this MenuPiece adds its items.
      Overrides:
      getMenu in class MenuPiece
      Returns:
      the menu
    • getRoot

      public RootMenuPiece getRoot()
      Gets the root of this subtree.
      Returns:
      the root