Package swingtree

Class UIForAnyWindow<I extends UIForAnyWindow<I,W>,W extends Window>

java.lang.Object
swingtree.UIForAnything<I,W,Component>
swingtree.UIForAnyWindow<I,W>
Type Parameters:
I - The type of the builder itself.
W - The type of the window which is being configured by this builder.
Direct Known Subclasses:
UIForJDialog, UIForJFrame

public abstract class UIForAnyWindow<I extends UIForAnyWindow<I,W>,W extends Window> extends UIForAnything<I,W,Component>
A SwingTree builder node for configuring any kind of Window type. Take a look at the UIForJDialog and UIForJFrame classes, which are specialized subtypes of this class.
  • Constructor Details

    • UIForAnyWindow

      public UIForAnyWindow()
  • Method Details

    • withTitle

      public final I withTitle(String title)
      Adds a title to the window.
      Note that the way this is displayed depends on the window type and the operating system.
      Parameters:
      title - The title to be shown in the top bar of the window.
      Returns:
      This builder.
    • withTitle

      public final I withTitle(sprouts.Val<String> title)
      Binds a text property to the window determining the title displayed in the top bar of the window.
      Note that the way this is displayed depends on the window type and the operating system.
      Parameters:
      title - The title property whose text will be shown in the top bar of the window.
      Returns:
      This builder.
    • withOnCloseOperation

      public final I withOnCloseOperation(UI.OnWindowClose onClose)
      Sets the UI.OnWindowClose operation for the window.
      This translates to JFrame.setDefaultCloseOperation(int) or JDialog.setDefaultCloseOperation(int) depending on the window type. The following operations are supported:
      Parameters:
      onClose - The operation to be executed when the window is closed.
      Returns:
      This declarative builder instance to enable method chaining.
    • show

      public abstract void show()
      Makes the window visible in the center of the screen.
    • _getRootPaneOf

      protected abstract Optional<JRootPane> _getRootPaneOf(W thisWindow)
    • _setTitleOf

      protected abstract void _setTitleOf(W thisWindow, String title)
    • onPressed

      public final I onPressed(Keyboard.Key key, sprouts.Action<WindowDelegate<W,ActionEvent>> onKeyPressed)
      Adds the supplied Action wrapped in a KeyListener to the component, to receive key events triggered when the wrapped component receives a particular keyboard input matching the provided Keyboard.Key.

      Parameters:
      key - The Keyboard.Key which should be matched to the key event.
      onKeyPressed - The Action which will be executed once the wrapped component received the targeted key press.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onFocusGain

      public final I onFocusGain(sprouts.Action<WindowDelegate<W,FocusEvent>> onFocus)
      Adds the supplied Action wrapped in a FocusListener to the component, to receive those focus events where the wrapped component gains input focus.
      Parameters:
      onFocus - The Action which should be executed once the input focus was gained on the wrapped component.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onFocusLoss

      public final I onFocusLoss(sprouts.Action<WindowDelegate<W,FocusEvent>> onFocus)
      Adds the supplied Action wrapped in a focus listener to receive those focus events where the wrapped component loses input focus.
      Parameters:
      onFocus - The Action which should be executed once the input focus was lost on the wrapped component.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onClose

      public final I onClose(sprouts.Action<WindowDelegate<W,WindowEvent>> onClose)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowClosing(WindowEvent) events which are invoked when a window is in the process of being closed. The close operation can be overridden at this point (see WindowConstants.DO_NOTHING_ON_CLOSE).
      Note that this kind of event is typically triggered when the user clicks the close button in the top bar of the window.
      Parameters:
      onClose - The Action which should be invoked when the wrapped component is in the process of being closed.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onClosed

      public final I onClosed(sprouts.Action<WindowDelegate<W,WindowEvent>> onClose)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowClosed(WindowEvent) events which are invoked when a window has been closed.
      Note that this kind of event is typically triggered when the user clicks the close button in the top bar of the window.
      Parameters:
      onClose - The Action which should be invoked when the wrapped component has been closed.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onOpened

      public final I onOpened(sprouts.Action<WindowDelegate<W,WindowEvent>> onOpen)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowOpened(WindowEvent) events which are invoked when a window has been opened.
      Note that this kind of event is typically triggered when the user clicks the close button in the top bar of the window.
      Parameters:
      onOpen - The Action which should be invoked when the wrapped component has been opened.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onIconified

      public final I onIconified(sprouts.Action<WindowDelegate<W,WindowEvent>> onIconify)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowIconified(WindowEvent) events which are invoked when a window is changed from a normal to a minimized state. For many platforms, a minimized window is displayed as the icon specified in the window's iconImage property.
      Minification is usually triggered when the user clicks the minimize button in the top bar of the window. But this depends on the operating system.
      Parameters:
      onIconify - The Action which should be invoked when the wrapped component has been iconified.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onDeiconified

      public final I onDeiconified(sprouts.Action<WindowDelegate<W,WindowEvent>> onDeiconify)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowDeiconified(WindowEvent) events which are invoked when a window is changed from a minimized to a normal state, usually by the user restoring it from the task bar.
      Parameters:
      onDeiconify - The Action which should be invoked when the wrapped component has been deiconified.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onActivated

      public final I onActivated(sprouts.Action<WindowDelegate<W,WindowEvent>> onActivate)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowActivated(WindowEvent) events which are invoked when the Window is set to be the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window. So this kind of event is usually triggered when the user makes the window active by clicking it.
      Parameters:
      onActivate - The Action which should be invoked when the wrapped component has been activated.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onDeactivated

      public final I onDeactivated(sprouts.Action<WindowDelegate<W,WindowEvent>> onDeactivate)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowListener.windowDeactivated(WindowEvent) events which are invoked when a Window is no longer the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window. This kind of event typically occurs when the user clicks another window in the task bar of the operating system.
      Parameters:
      onDeactivate - The Action which should be invoked when the wrapped component has been deactivated.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onStateChanged

      public final I onStateChanged(sprouts.Action<WindowDelegate<W,WindowEvent>> onStateChanged)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowStateListener.windowStateChanged(WindowEvent) events which are invoked when a window has been changed.
      Note that this kind of event is typically invoked when the window is iconified, minimized, maximized or restored.
      Parameters:
      onStateChanged - The Action which should be invoked when the wrapped component has been changed.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onInputFocusGained

      public final I onInputFocusGained(sprouts.Action<WindowDelegate<W,WindowEvent>> onFocusGained)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowFocusListener.windowGainedFocus(WindowEvent) events which are invoked when the window is set to be gaining input focus, which means that the Window, or one of its subcomponents, will receive keyboard events. This event is typically triggered when the user clicks the window.
      Parameters:
      onFocusGained - The Action which should be invoked when the wrapped component has gained input focus.
      Returns:
      This very instance, which enables builder-style method chaining.
    • onInputFocusLost

      public final I onInputFocusLost(sprouts.Action<WindowDelegate<W,WindowEvent>> onFocusLost)
      Adds the supplied Action wrapped in a WindowListener to the component, to receive WindowFocusListener.windowLostFocus(WindowEvent) events which are invoked when the window is set to be losing input focus, which means that input focus is being transferred to another Window or no Window at all and that keyboard events will no longer be delivered to the Window or any of its subcomponents.
      Parameters:
      onFocusLost - The Action which should be invoked when the wrapped component has lost input focus.
      Returns:
      This very instance, which enables builder-style method chaining.