Package swingtree

Class UIForPopup<P extends JPopupMenu>


public final class UIForPopup<P extends JPopupMenu> extends UIForAnySwing<UIForPopup<P>,P>
A SwingTree builder node designed for configuring JPopupMenu instances.

Take a look at the living swing-tree documentation where you can browse a large collection of examples demonstrating how to use the API of this class or other classes.

  • Method Details

    • _state

      protected swingtree.BuilderState<P> _state()
      Description copied from class: UIForAnything
      Returns the state of the builder, which is a container for the wrapped component as well as it's type and current EventProcessor.
      Specified by:
      _state in class UIForAnything<UIForPopup<P extends JPopupMenu>,P extends JPopupMenu,JComponent>
      Returns:
      The state of the builder.
    • _newBuilderWithState

      protected UIForPopup<P> _newBuilderWithState(swingtree.BuilderState<P> newState)
      Description copied from class: UIForAnything
      An internal wither method which creates a new builder instance with the provided BuilderState stored inside it.
      Specified by:
      _newBuilderWithState in class UIForAnything<UIForPopup<P extends JPopupMenu>,P extends JPopupMenu,JComponent>
      Parameters:
      newState - The new state which should be stored inside the new builder instance.
      Returns:
      A new builder instance with the provided state stored inside it.
    • borderIsPaintedIf

      public final UIForPopup<P> borderIsPaintedIf(boolean borderPainted)
      Determines if the border is painted or not.
      Parameters:
      borderPainted - True if the border is painted, false otherwise
      Returns:
      This builder node, to qllow for method chaining.
    • borderIsPaintedIf

      public final UIForPopup<P> borderIsPaintedIf(sprouts.Val<Boolean> isPainted)
      Determines if the border is painted or not based on the value of the given Val. If the value of the Val changes, the border will be painted or not.
      Parameters:
      isPainted - A Val which will be used to determine if the border is painted or not.
      Returns:
      This builder node, to qllow for method chaining.
    • onVisible

      public UIForPopup<P> onVisible(sprouts.Action<ComponentDelegate<P,PopupMenuEvent>> action)
      Registers a listener to be notified when the popup is shown. This is typically triggered when JPopupMenu.show(Component, int, int) is called.
      Parameters:
      action - The action to be executed when the popup is shown.
      Returns:
      this
    • onInvisible

      public UIForPopup<P> onInvisible(sprouts.Action<ComponentDelegate<P,PopupMenuEvent>> action)
      Registers a listener to be notified when the popup becomes invisible, meaning its popup menu is hidden.
      Parameters:
      action - The action to be executed when the popup becomes invisible.
      Returns:
      This builder node, to allow for method chaining.
    • onCancel

      public UIForPopup<P> onCancel(sprouts.Action<ComponentDelegate<P,PopupMenuEvent>> action)
      Registers a listener to be notified when the popup is canceled. This is typically triggered when the user clicks outside the popup.
      Parameters:
      action - the action to be executed when the popup is canceled.
      Returns:
      this
    • add

      public UIForPopup<P> add(JMenuItem item)
    • add

      public UIForPopup<P> add(JSeparator separator)
    • add

      public UIForPopup<P> add(JPanel panel)