Package swingtree

Class UIFactoryMethods

java.lang.Object
swingtree.UILayoutConstants
swingtree.UIFactoryMethods
Direct Known Subclasses:
UI

public abstract class UIFactoryMethods extends UILayoutConstants
A namespace for useful factory methods like color(String) and font(String), and layout constants (see UILayoutConstants).
This class is intended to be used by the UI namespace class ONLY!
Please do not inherit or import this class in your own code, as it is not intended to be used outside of the UI namespace.
  • Constructor Details

    • UIFactoryMethods

      public UIFactoryMethods()
  • Method Details

    • color

      public static UI.Color color(int r, int g, int b)
      Creates a new Color object from the specified red, green and blue values.
      Parameters:
      r - The red value (0-255).
      g - The green value (0-255).
      b - The blue value (0-255).
      Returns:
      The new color.
    • color

      public static UI.Color color(int r, int g, int b, int a)
      Creates a new Color object from the specified red, green, blue and alpha values.
      Parameters:
      r - The red value (0-255).
      g - The green value (0-255).
      b - The blue value (0-255).
      a - The alpha value (0-255).
      Returns:
      The new color.
    • color

      public static UI.Color color(double r, double g, double b)
      Creates a new Color object from the specified red, green and blue values.
      Parameters:
      r - The red value (0.0-1.0).
      g - The green value (0.0-1.0).
      b - The blue value (0.0-1.0).
      Returns:
      The new color.
    • color

      public static UI.Color color(double r, double g, double b, double a)
      Creates a new Color object from the specified red, green, blue and alpha values.
      Parameters:
      r - The red value (0.0-1.0).
      g - The green value (0.0-1.0).
      b - The blue value (0.0-1.0).
      a - The alpha value (0.0-1.0).
      Returns:
      The new color.
    • color

      public static UI.Color color(String colorAsString)
      Tries to parse the supplied string as a color value based on various formats.
      Parameters:
      colorAsString - The string to parse.
      Returns:
      The parsed color.
      Throws:
      IllegalArgumentException - If the string could not be parsed.
      NullPointerException - If the string is null.
    • font

      public static UI.Font font(String fontString)
      Returns the Font that the fontString argument describes. To ensure that this method returns the desired Font, format the fontString parameter in one of these ways
      • fontname-style-pointsize
      • fontname-pointsize
      • fontname-style
      • fontname
      • fontname style pointsize
      • fontname pointsize
      • fontname style
      • fontname
      in which style is one of the four case-insensitive strings: "PLAIN", "BOLD", "BOLDITALIC", or "ITALIC", and pointsize is a positive decimal integer representation of the point size. For example, if you want a font that is Arial, bold, with a point size of 18, you would call this method with: "Arial-BOLD-18". This is equivalent to calling the Font constructor : new Font("Arial", Font.BOLD, 18); and the values are interpreted as specified by that constructor.

      A valid trailing decimal field is always interpreted as the pointsize. Therefore a fontname containing a trailing decimal value should not be used in the fontname only form.

      If a style name field is not one of the valid style strings, it is interpreted as part of the font name, and the default style is used.

      Only one of ' ' or '-' may be used to separate fields in the input. The identified separator is the one closest to the end of the string which separates a valid pointsize, or a valid style name from the rest of the string. Null (empty) pointsize and style fields are treated as valid fields with the default value for that field.

      Some font names may include the separator characters ' ' or '-'. If fontString is not formed with 3 components, e.g. such that style or pointsize fields are not present in fontString, and fontname also contains a character determined to be the separator character then these characters where they appear as intended to be part of fontname may instead be interpreted as separators so the font name may not be properly recognised.

      The default size is 12 and the default style is PLAIN. If str does not specify a valid size, the returned Font has a size of 12. If fontString does not specify a valid style, the returned Font has a style of PLAIN. If you do not specify a valid font name in the fontString argument, this method will return a font with the family name "Dialog". To determine what font family names are available on your system, use the GraphicsEnvironment.getAvailableFontFamilyNames() method. If fontString is null, a new Font is returned with the family name "Dialog", a size of 12 and a PLAIN style.

      Parameters:
      fontString - the name of the font, or null
      Returns:
      the Font object that fontString describes.
      Throws:
      NullPointerException - if fontString is null
    • of

      public static <T extends JComponent> UIForSwing<T> of(T component)
      This returns an instance of a generic swing tree builder for anything extending the JComponent class.

      Type Parameters:
      T - The concrete type of this new component.
      Parameters:
      component - The new component instance which ought to be part of the Swing UI.
      Returns:
      A basic UI builder instance wrapping any JComponent.
    • of

      public static <P extends JPanel> UIForPanel<P> of(P component)
      Use this to create a builder for the provided JPanel type.
      This method is typically used to enable declarative UI design for custom JPanel based components either within the constructor of a custom subclass, like so:
      
        class MyCustomPanel extends JPanel {
            public MyCustomPanel() {
                UI.of(this)
                .add(UI.label("Hello Swing!"))
                .add(UI.button("Click Me"))
                .add(UI.button("Or Me") );
            }
        }
        

      ... or as part of a UI declaration, where the custom JPanel type is added to the components tree, like so:
      
        UI.show(
            UI.panel()
            .add(
                new MyCustomPanel()
            )
            .add(..more stuff..)
        );
        

      Type Parameters:
      P - The type parameter of the concrete JPanel type to be wrapped.
      Parameters:
      component - The JPanel instance to be wrapped by a swing tree UI builder for panel components.
      Returns:
      A builder instance for the provided JPanel, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • panel

      public static UIForPanel<JPanel> panel()
      Use this to create a builder for a new JPanel UI component with a MigLayout as its layout manager. This is in essence a convenience method for UI.of(new JPanel(new MigLayout())).
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
    • panel

      public static UIForPanel<JPanel> panel(String attr)
      Use this to create a builder for the JPanel UI component. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(new MigLayout(attr)))
        

      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(String attr, String colConstraints)
      Use this to create a builder for the JPanel UI component. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(new MigLayout(attr, colConstraints)))
        

      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      colConstraints - The layout which will be passed to the MigLayout constructor as second argument.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(String attr, String colConstraints, String rowConstraints)
      Use this to create a builder for a new JPanel UI component with a MigLayout as its layout manager and the provided constraints. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(new MigLayout(attr, colConstraints, rowConstraints)))
        

      Parameters:
      attr - The layout attributes.
      colConstraints - The column constraints.
      rowConstraints - The row constraints.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(LayoutConstraint attr)
      Use this to create a builder for the JPanel UI component. This is in essence a convenience method for UI.of(new JPanel()).withLayout(attr).
      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(LayoutConstraint attr, String colConstraints)
      Use this to create a builder for the JPanel UI component. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(new MigLayout(attr, colConstraints)))
        

      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      colConstraints - The layout which will be passed to the MigLayout constructor as second argument.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(LayoutConstraint attr, String colConstraints, String rowConstraints)
      Use this to create a builder for a new JPanel UI component with a MigLayout as its layout manager and the provided constraints. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(new MigLayout(attr, colConstraints, rowConstraints)))
        

      Parameters:
      attr - The layout attributes in the form of a LayoutConstraint constants.
      colConstraints - The column constraints.
      rowConstraints - The row constraints.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(net.miginfocom.layout.LC attr)
      Use this to create a builder for the JPanel UI component. This is in essence a convenience method for UI.of(new JPanel()).withLayout(attr).
      This method is typiclly used alongside the UILayoutConstants.LC() factory method to create a layout attributes/constraints builder, like so:
      
            UI.panel(
                UI.LC()
                .insets("10 10 10 10")
                .debug()
            )
            .add(..)
            .add(..)
        
      Parameters:
      attr - The constraint attributes concerning the entire MigLayout in the form of a LC instance.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(net.miginfocom.layout.LC attr, String colConstraints)
      Use this to create a builder for a new JPanel UI component with a MigLayout as its layout manager and the provided constraints. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(new MigLayout(attr, ConstraintParser.parseColumnConstraints(colConstraints))))
        

      Parameters:
      attr - The layout attributes in the form of a LC constants.
      colConstraints - The column constraints in the form of a String instance.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(net.miginfocom.layout.LC attr, String colConstraints, String rowConstraints)
      Use this to create a builder for a new JPanel UI component with a MigLayout as its layout manager and the provided constraints. This is essentially a convenience method for the following:
      
            UI.of(new JPanel(
                new MigLayout(
                    attr,
                    ConstraintParser.parseColumnConstraints(colConstraints),
                    ConstraintParser.parseRowConstraints(rowConstraints)
                )
            ))
        

      Parameters:
      attr - The layout attributes in the form of a LC instance.
      colConstraints - The column constraints in the form of a String instance.
      rowConstraints - The row constraints in the form of a String instance.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      See Also:
    • panel

      public static UIForPanel<JPanel> panel(sprouts.Val<LayoutConstraint> attr)
      Use this to create a builder for the JPanel UI component with a dynamically updated set of MigLayout constraints/attributes. This is in essence a convenience method for UI.of(new JPanel()).withLayout(attr).
      Parameters:
      attr - The layout attributes property which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a new JPanel, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • of

      public static <B extends JBox> UIForBox<B> of(B component)
      Use this to create a builder for the provided JBox instance, which is a general purpose component wrapper type with the following properties:
      • It is transparent, meaning that it does not paint its background.
      • The default layout manager is a MigLayout.
      • The insets (the space between the wrapped component and the box's border) are set to zero.
      • There the gap size between the components added to the box is set to zero. So they will be tightly packed.
      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...

      This method is typically used to enable declarative UI design for custom JBox based components either within the constructor of a custom subclass, like so:

      
        class MyCustomBox extends JBox {
            public MyCustomBox() {
                UI.of(this)
                .add(UI.label("Hello Swing!"))
                .add(UI.button("Click Me"))
                .add(UI.button("Or Me") );
            }
        }
        

      ... or as part of a UI declaration, where the custom JBox type is added to the components tree, like so:
      
        UI.show(
            UI.panel()
            .add(
                new MyCustomBox()
            )
            .add(..more stuff..)
        );
        

      Type Parameters:
      B - THe type parameter defining the concrete JBox type.
      Parameters:
      component - The box component type for which a builder should be created.
      Returns:
      A builder for the provided box component.
      Throws:
      IllegalArgumentException - if component is null.
    • box

      public static UIForBox<JBox> box()
      Use this to create a builder for a JBox instance, which is a general purpose component wrapper type with the following properties:
      • It is transparent, meaning that it does not paint its background.
      • The default layout manager is a MigLayout.
      • The insets (the spaces between the wrapped component and the box's border) are all set to zero.
      • The gap sizes between the components added to the box is set to zero. So the children of this component will be tightly packed.
      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...

      This factory method is especially useful for when you simply want to nest components tightly without having to worry about the layout manager or the background color covering the background of the parent component.
      Note that you can also emulate the JBox type with a JPanel using UI.panel("ins 0, gap 0").makeNonOpaque().

      Returns:
      A builder instance for a new JBox, which enables fluent method chaining.
    • box

      public static UIForBox<JBox> box(String attr)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager. This is conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints.
      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a new JBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • box

      public static UIForBox<JBox> box(String attr, String colConstraints)
      Use this to create a builder for a JBox, conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints.
      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...
      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      colConstraints - The layout which will be passed to the MigLayout constructor as second argument.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      See Also:
    • box

      public static UIForBox<JBox> box(String attr, String colConstraints, String rowConstraints)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager. This factory method is especially useful for when you simply want to nest components tightly without having to worry about the layout manager or the background color covering the background of the parent component.
      Note that you can also emulate the JBox type with a JPanel using
      
            UI.panel(attr, colConstraints, rowConstraints).makeNonOpaque()
        

      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...

      Parameters:
      attr - The layout attributes.
      colConstraints - The column constraints.
      rowConstraints - The row constraints.
      Returns:
      A builder instance for a new JBox, which enables fluent method chaining.
      See Also:
    • box

      public static UIForBox<JBox> box(LayoutConstraint attr)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager. This is conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints.
      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...


      This method allows you to pass a LayoutConstraint constants as the layout attributes, which is an instance typically chosen from the UI class constants like for example UILayoutConstants.FILL, UILayoutConstants.FILL_X, UILayoutConstants.FILL_Y...
      A typical usage example would be:

      
            UI.box(UI.FILL_X.and(UI.WRAP(2)))
            .add(..)
            .add(..)
        
      In this code snippet the creates a JBox with a MigLayout as its layout manager where the box will fill the parent component horizontally and the components added to the box will be wrapped after every two components.
      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • box

      public static UIForBox<JBox> box(LayoutConstraint attr, String colConstraints)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager. This is conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints.
      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...

      This method allows you to pass a LayoutConstraint constants as the layout attributes, which is an instance typically chosen from the UI class constants like for example UILayoutConstants.FILL, UILayoutConstants.FILL_X, UILayoutConstants.FILL_Y...
      A typical usage example would be:

      
            UI.box(UI.FILL, "[shrink]6[grow]")
            .add(..)
            .add(..)
        
      In this code snippet the creates a JBox with a MigLayout as its layout manager where the box will fill the parent component horizontally and vertically and the first column of components will be shrunk to their preferred size and the second column will grow to fill the available space. Both columns will have a gap of 6 pixels between them.
      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      colConstraints - The layout which will be passed to the MigLayout constructor as second argument.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      See Also:
    • box

      public static UIForBox<JBox> box(LayoutConstraint attr, String colConstraints, String rowConstraints)
      Use this to create a builder for a JBox, conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints. This is essentially a convenience method for the following:
      
            UI.of(new JBox(new MigLayout(attr, colConstraints, rowConstraints)))
        

      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...
      Parameters:
      attr - The layout attributes in the form of a LayoutConstraint constants.
      colConstraints - The column constraints.
      rowConstraints - The row constraints.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      See Also:
    • box

      public static UIForBox<JBox> box(net.miginfocom.layout.LC attr)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager.
      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...
      Parameters:
      attr - The layout attributes which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • box

      public static UIForBox<JBox> box(net.miginfocom.layout.LC attr, String colConstraints)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager. This is conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints. This is essentially a convenience method which may also be expressed as:
      
            UI.of(new JBox(new MigLayout(attr, colConstraints)))
        

      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...
      Parameters:
      attr - The layout attributes in the form of a LayoutConstraint constants.
      colConstraints - The column constraints.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      See Also:
    • box

      public static UIForBox<JBox> box(net.miginfocom.layout.LC attr, String colConstraints, String rowConstraints)
      Use this to create a builder for a JBox, conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints. This is essentially a convenience method which may also be expressed as:
      
            UI.of(new JBox())
            .peek( box -> {
                box.setLayout(
                    new MigLayout(
                        attr,
                        ConstraintParser.parseColumnConstraints(colConstraints),
                        ConstraintParser.parseRowConstraints(rowConstraints)
                    )
                )
            })
        

      Please note that the JBox type is in no way related to the BoxLayout! The term box is referring to the purpose of this component, which is to tightly store and wrap other sub-components seamlessly...
      Parameters:
      attr - The layout attributes in the form of a LayoutConstraint constants.
      colConstraints - The column constraints.
      rowConstraints - The row constraints.
      Returns:
      A builder instance for a transparent JBox, which enables fluent method chaining.
      See Also:
    • box

      public static UIForBox<JBox> box(sprouts.Val<LayoutConstraint> attr)
      Use this to create a builder for a JBox, a generic component wrapper type which is transparent and without any insets as well as with a MigLayout as its layout manager. This is conceptually the same as a transparent JPanel without any insets and a MigLayout constructed using the provided constraints. This method allows you to dynamically determine the LayoutConstraint constants of the MigLayout instance, by passing a Val property which will be observed and its value passed to the MigLayout constructor whenever it changes. This is in essence a convenience method for: UI.box().withLayout(attr.viewAsString( it -> it+", ins 0")).
      Parameters:
      attr - The layout attributes property which will be passed to the MigLayout constructor as first argument.
      Returns:
      A builder instance for a new JBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if attr is null.
      See Also:
    • of

      public static <T extends JComponent> UIForSwing<T> of(SwingBuilder<T> builder)
      If you are using builders for your custom JComponent, implement this to allow the UI API to call the SwingBuilder.build() method for you.
      Type Parameters:
      T - The UI component type built by implementations of the provided builder.
      Parameters:
      builder - A builder for custom JComponent types.
      Returns:
      A basic UI builder instance wrapping any JComponent.
    • of

      public static <M extends JMenuItem> UIForMenuItem<M> of(MenuBuilder<M> builder)
      If you are using builders for custom JMenuItem components, implement this to allow the UI API to call the SwingBuilder.build() method for you.
      Type Parameters:
      M - The JMenuItem type built by implementations of the provided builder.
      Parameters:
      builder - A builder for custom JMenuItem types.
      Returns:
      A builder instance for a JMenuItem, which enables fluent method chaining.
    • of

      public static <P extends JPopupMenu> UIForPopup<P> of(P popup)
      Use this to create a swing tree builder node for the JPopupMenu UI component.
      Type Parameters:
      P - The concrete type of this new component.
      Parameters:
      popup - The new JPopupMenu instance which ought to be part of the Swing UI.
      Returns:
      A builder instance for a JPopupMenu, which enables fluent method chaining.
    • popupMenu

      public static UIForPopup<JPopupMenu> popupMenu()
      Use this to create a swing tree builder node for the JPopupMenu UI component. This is in essence a convenience method for UI.of(new JPopupMenu()).
      Returns:
      A builder instance for a JPopupMenu, which enables fluent method chaining.
    • of

      public static <S extends JSeparator> UIForSeparator<S> of(S separator)
      This returns an instance of a UIForSeparator builder responsible for building a JSeparator by exposing helpful utility methods for it.
      Type Parameters:
      S - The concrete type of this new component.
      Parameters:
      separator - The new JSeparator instance which ought to be part of the Swing UI.
      Returns:
      A UIForSeparator UI builder instance which wraps the JSeparator and exposes helpful methods.
    • separator

      public static UIForSeparator<JSeparator> separator()
      This returns an instance of a UIForSeparator builder responsible for building a JSeparator by exposing helpful utility methods for it. This is in essence a convenience method for UI.of(new JSeparator()).
      Returns:
      A UIForSeparator UI builder instance which wraps the JSeparator and exposes helpful methods.
    • separator

      public static UIForSeparator<JSeparator> separator(UI.Align align)
      This returns an instance of a UIForSeparator builder responsible for building a JSeparator by exposing helpful utility methods for it. This is in essence a convenience method for UI.of(new JSeparator(JSeparator.VERTICAL)).
      Parameters:
      align - The alignment of the separator which may either be horizontal or vertical.
      Returns:
      A UIForSeparator UI builder instance which wraps the JSeparator and exposes helpful methods.
    • separator

      public static UIForSeparator<JSeparator> separator(sprouts.Val<UI.Align> align)
      Use this to create a swing tree builder node for the JSeparator whose alignment is dynamically determined based on a provided property.
      Parameters:
      align - The alignment property of the separator which may either be horizontal or vertical.
      Returns:
      A UIForSeparator UI builder instance which wraps the JSeparator and exposes helpful methods.
    • of

      public static <T extends AbstractButton> UIForButton<T> of(T component)
      This returns a JButton swing tree builder.
      Type Parameters:
      T - The concrete type of this new component.
      Parameters:
      component - The button component which ought to be wrapped by the swing tree UI builder.
      Returns:
      A basic UI JButton builder instance.
    • button

      public static UIForButton<JButton> button()
      Use this to create a builder for the JButton UI component without any text displayed on top. This is in essence a convenience method for UI.of(new JButton()).
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(String text)
      Use this to create a builder for the JButton UI component with the provided text displayed on top. This is in essence a convenience method for UI.of(new JButton(String text)).
      Parameters:
      text - The text to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(sprouts.Val<String> text)
      Create a builder for the JButton UI component where the text of the provided property is dynamically displayed on top.
      Parameters:
      text - The text property to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(Icon icon)
      Use this to create a builder for the JButton UI component with an icon displayed on top. This is in essence a convenience method for UI.of(new JButton()).peek( it -> it.setIcon(icon) ).
      Parameters:
      icon - The icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(ImageIcon icon, UI.FitComponent fit)
      Use this to create a builder for the JButton UI component with an icon displayed on top.
      Parameters:
      icon - The icon to be displayed on top of the button.
      fit - The fit mode of the icon.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(IconDeclaration icon)
      Use this to create a builder for the JButton UI component with an icon displayed on top. The icon is determined based on the provided IconDeclaration instance which is conceptually merely a resource path to the icon.
      Parameters:
      icon - The desired icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(IconDeclaration icon, UI.FitComponent fit)
      Use this to create a builder for the JButton UI component with an icon displayed on top. The icon is determined based on the provided IconDeclaration instance which is conceptually merely a resource path to the icon.
      Parameters:
      icon - The desired icon to be displayed on top of the button.
      fit - The fit mode of the icon.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(int width, int height, ImageIcon icon)
      Use this to create a builder for the JButton UI component with an icon displayed on top which should be scaled to the provided dimensions. This is in essence a convenience method for UI.of(new JButton()).peek( it -> it.setIcon(icon) ).
      Parameters:
      width - The width the icon should be scaled to.
      height - The height the icon should be scaled to.
      icon - The icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(int width, int height, IconDeclaration icon)
      Use this to create a builder for the JButton UI component with an icon displayed on top which should be scaled to the provided dimensions. The icon is determined based on the provided IconDeclaration instance which is conceptually merely a resource path to the icon.
      Parameters:
      width - The width the icon should be scaled to.
      height - The height the icon should be scaled to.
      icon - The desired icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • buttonWithIcon

      public static UIForButton<JButton> buttonWithIcon(sprouts.Val<IconDeclaration> icon)
      Use this to create a builder for the JButton UI component with a dynamically displayed icon on top.

      Note that you may not use the Icon or ImageIcon classes directly, instead you must use implementations of the IconDeclaration interface, which merely models the resource location of the icon, but does not load the whole icon itself.

      The reason for this distinction is the fact that traditional Swing icons are heavy objects whose loading may or may not succeed, and so they are not suitable for direct use in a property as part of your view model. Instead, you should use the IconDeclaration interface, which is a lightweight value object that merely models the resource location of the icon even if it is not yet loaded or even does not exist at all.

      This is especially useful in case of unit tests for you view model, where the icon may not be available at all, but you still want to test the behaviour of your view model.

      Parameters:
      icon - The icon property whose value ought to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(Icon icon, Icon onHover)
      Use this to create a builder for the JButton UI component with a default icon as well as a hover icon displayed on top.
      Parameters:
      icon - The default icon to be displayed on top of the button.
      onHover - The hover icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(IconDeclaration icon, IconDeclaration onHover)
      Use this to create a builder for the JButton UI component with a default icon as well as a hover icon displayed on top. The icons are determined based on the provided IconDeclaration instances which is conceptually merely a resource paths to the icons.
      Parameters:
      icon - The default icon to be displayed on top of the button.
      onHover - The hover icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(int width, int height, ImageIcon icon, ImageIcon onHover)
      Use this to create a builder for the JButton UI component with a default icon as well as a hover icon displayed on top which should both be scaled to the provided dimensions.
      Parameters:
      width - The width the icons should be scaled to.
      height - The height the icons should be scaled to.
      icon - The default icon to be displayed on top of the button.
      onHover - The hover icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(int width, int height, IconDeclaration icon, IconDeclaration onHover)
      Use this to create a builder for the JButton UI component with a default icon as well as a hover icon displayed on top which should both be scaled to the provided dimensions. The icons are determined based on the provided IconDeclaration instances which is conceptually merely a resource paths to the icons.
      Parameters:
      width - The width the icons should be scaled to.
      height - The height the icons should be scaled to.
      icon - The default icon to be displayed on top of the button.
      onHover - The hover icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(Icon icon, Icon onHover, Icon onPress)
      Use this to create a builder for the JButton UI component with a default, an on-hover and an on-press icon displayed on top. This is in essence a convenience method for:
      
            UI.of(new JButton()).peek( it -> {
                it.setIcon(icon);
                it.setRolloverIcon(onHover);
                it.setPressedIcon(onPress);
            })
        
      Parameters:
      icon - The default icon to be displayed on top of the button.
      onHover - The hover icon to be displayed on top of the button.
      onPress - The pressed icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • button

      public static UIForButton<JButton> button(IconDeclaration icon, IconDeclaration onHover, IconDeclaration onPress)
      Use this to create a builder for the JButton UI component with a default, an on-hover and an on-press icon displayed on top. The icons are determined based on the provided IconDeclaration instances which is conceptually merely a resource paths to the icons.
      Parameters:
      icon - The default icon to be displayed on top of the button.
      onHover - The hover icon to be displayed on top of the button.
      onPress - The pressed icon to be displayed on top of the button.
      Returns:
      A builder instance for a JButton, which enables fluent method chaining.
    • of

      public static <B extends JSplitButton> UIForSplitButton<B> of(B splitButton)
      Use this to create a builder for the JSplitButton UI component. This is in essence a convenience method for UI.of(new JSplitButton()).
      Type Parameters:
      B - The concrete type of this new component.
      Parameters:
      splitButton - The split button component which ought to be wrapped by the swing tree UI builder.
      Returns:
      A builder instance for a JSplitButton, which enables fluent method chaining.
    • splitButton

      public static UIForSplitButton<JSplitButton> splitButton(String text)
      Use this to build JSplitButtons with custom text displayed ont top. The JSplitButton wrapped by the returned builder can be populated with JMenuItems like so:
      
            UI.splitButton("Displayed on button!")
            .add(UI.splitItem("first"))
            .add(UI.splitItem("second").onButtonClick( it -> ... ))
            .add(UI.splitItem("third"))
        
      Parameters:
      text - The text which should be displayed on the wrapped JSplitButton
      Returns:
      A UI builder instance wrapping a JSplitButton.
    • splitButton

      public static <E extends Enum<E>> UIForSplitButton<JSplitButton> splitButton(sprouts.Var<E> selection, sprouts.Event clickEvent)
      Use this to build JSplitButtons where the selectable options are represented by an Enum type, and the click event is handles by an Event instance.
      Here's an example of how to use this method:
      
            // In your view model:
            enum Size { SMALL, MEDIUM, LARGE }
            private Var<Size> selection = Var.of(Size.SMALL);
            private Event clickEvent = Event.of(()->{ ... }
      
            public Var<Size> selection() { return selection; }
            public Event clickEvent() { return clickEvent; }
      
            // In your view:
            UI.splitButton(vm.selection(), vm.clickEvent())
       

      Tip: For the text displayed on the split button, the selected enum state will be converted to strings based on the Object.toString() method. If you want to customize how they are displayed (So that 'Size.LARGE' is displayed as 'Large' instead of 'LARGE') simply override the Object.toString() method in your enum.

      Type Parameters:
      E - The type of the Enum representing the selectable options.
      Parameters:
      selection - The Var which holds the currently selected Enum value. This will be updated when the user selects a new value.
      clickEvent - The Event which will be fired when the user clicks on the button.
      Returns:
      A UI builder instance wrapping a JSplitButton.
    • splitButton

      public static <E extends Enum<E>> UIForSplitButton<JSplitButton> splitButton(sprouts.Var<E> selection)
      Use this to build JSplitButtons where the selectable options are represented by an Enum type.
      Here's an example of how to use this method:
      
            // In your view model:
            enum Size { SMALL, MEDIUM, LARGE }
            private Var<Size> selection = Var.of(Size.SMALL);
      
            public Var<Size> selection() { return selection; }
      
            // In your view:
            UI.splitButton(vm.selection())
       

      Tip: The text displayed on the button is based on the Object.toString() method of the enum instances. If you want to customize how they are displayed (So that 'Size.LARGE' is displayed as 'Large' instead of 'LARGE') simply override the Object.toString() method in your enum.

      Type Parameters:
      E - The type of the Enum representing the selectable options.
      Parameters:
      selection - The Var which holds the currently selected Enum value. This will be updated when the user selects a new value.
      Returns:
      A UI builder instance wrapping a JSplitButton.
    • splitItem

      public static SplitItem<JMenuItem> splitItem(String text)
      Use this to add entries to the JSplitButton by passing SplitItem instances to UIForSplitButton builder like so:
      
            UI.splitButton("Button")
            .add(UI.splitItem("first"))
            .add(UI.splitItem("second"))
            .add(UI.splitItem("third"))
        
      You can also use the SplitItem wrapper class to wrap useful action lambdas for the split item.
      Parameters:
      text - The text displayed on the JMenuItem exposed by the JSplitButtons JPopupMenu.
      Returns:
      A new SplitItem wrapping a simple JMenuItem.
    • splitItem

      public static SplitItem<JMenuItem> splitItem(sprouts.Val<String> text)
      Use this to add property bound entries to the JSplitButton by passing SplitItem instances to UIForSplitButton builder like so:
      
            UI.splitButton("Button")
            .add(UI.splitItem(viewModel.getFirstButtonName()))
            .add(UI.splitItem(viewModel.getSecondButtonName()))
            .add(UI.splitItem(viewModel.getThirdButtonName()))
        
      You can also use the SplitItem wrapper class to wrap useful action lambdas for the split item.
      Parameters:
      text - The text property to dynamically display text on the JMenuItem exposed by the JSplitButtons JPopupMenu.
      Returns:
      A new SplitItem wrapping a simple JMenuItem.
    • splitRadioItem

      public static SplitItem<JRadioButtonMenuItem> splitRadioItem(String text)
      Use this to add radio item entries to the JSplitButton by passing SplitItem instances to UIForSplitButton builder like so:
      
            UI.splitButton("Button")
            .add(UI.splitRadioItem("first"))
            .add(UI.splitRadioItem("second"))
            .add(UI.splitRadioItem("third"))
        
      You can also use the SplitItem wrapper class to wrap useful action lambdas for the split item.
      Parameters:
      text - The text displayed on the JRadioButtonMenuItem exposed by the JSplitButtons JPopupMenu.
      Returns:
      A new SplitItem wrapping a simple JRadioButtonMenuItem.
    • of

      public static <P extends JTabbedPane> UIForTabbedPane<P> of(P pane)
      Creates a UI builder for a custom JTabbedPane type.
      Type Parameters:
      P - The pane type parameter.
      Parameters:
      pane - The JTabbedPane type which should be used wrapped.
      Returns:
      This instance, to allow for method chaining.
    • tabbedPane

      public static UIForTabbedPane<JTabbedPane> tabbedPane()
      Use this to create a builder for a new JTabbedPane UI component. This is in essence a convenience method for UI.of(new JTabbedPane()). In order to add tabs to this builder use the tab object returned by tab(String) like so:
      
            UI.tabbedPane()
            .add(UI.tab("one").add(UI.panel().add(..)))
            .add(UI.tab("two").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("three").withIcon(someIcon).add(UI.button("click me")))
        
      Returns:
      A builder instance for a new JTabbedPane, which enables fluent method chaining.
    • tabbedPane

      public static UIForTabbedPane<JTabbedPane> tabbedPane(UI.Side tabsSide)
      Use this to create a builder for a new JTabbedPane UI component with the provided UI.Side applied to the tab buttons (see JTabbedPane.setTabLayoutPolicy(int)). In order to add tabs to this builder use the tab object returned by tab(String) like so:
      
            UI.tabbedPane(Position.RIGHT)
            .add(UI.tab("first").add(UI.panel().add(..)))
            .add(UI.tab("second").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("third").withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      tabsSide - The position of the tab buttons which may be UI.Side.TOP, UI.Side.RIGHT, UI.Side.BOTTOM, UI.Side.LEFT.
      Returns:
      A builder instance wrapping a new JTabbedPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if tabsPosition is null.
    • tabbedPane

      public static UIForTabbedPane<JTabbedPane> tabbedPane(UI.Side tabsSide, UI.OverflowPolicy tabsPolicy)
      Use this to create a builder for a new JTabbedPane UI component with the provided UI.OverflowPolicy and UI.Side applied to the tab buttons (see JTabbedPane.setTabLayoutPolicy(int) and JTabbedPane.setTabPlacement(int)). In order to add tabs to this builder use the tab object returned by tab(String) like so:
      
            UI.tabbedPane(Position.LEFT, OverflowPolicy.WRAP)
            .add(UI.tab("First").add(UI.panel().add(..)))
            .add(UI.tab("second").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("third").withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      tabsSide - The position of the tab buttons which may be UI.Side.TOP, UI.Side.RIGHT, UI.Side.BOTTOM, UI.Side.LEFT.
      tabsPolicy - The overflow policy of the tab buttons which can either be UI.OverflowPolicy.SCROLL or UILayoutConstants.WRAP(int).
      Returns:
      A builder instance wrapping a new JTabbedPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if tabsPosition or tabsPolicy are null.
    • tabbedPane

      public static UIForTabbedPane<JTabbedPane> tabbedPane(UI.OverflowPolicy tabsPolicy)
      Use this to create a builder for a new JTabbedPane UI component with the provided UI.OverflowPolicy applied to the tab buttons (see JTabbedPane.setTabLayoutPolicy(int)). In order to add tabs to this builder use the tab object returned by tab(String) like so:
      
            UI.tabbedPane(OverflowPolicy.SCROLL)
            .add(UI.tab("First").add(UI.panel().add(..)))
            .add(UI.tab("second").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("third").withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      tabsPolicy - The overflow policy of the tab button which can either be UI.OverflowPolicy.SCROLL or UILayoutConstants.WRAP(int).
      Returns:
      A builder instance wrapping a new JTabbedPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if tabsPolicy is null.
    • tabbedPane

      public static UIForTabbedPane<JTabbedPane> tabbedPane(sprouts.Val<Integer> selectedIndex)
      Use this to create a builder for a new JTabbedPane UI component with the provided selectedIndex property which should be determined the tab selection of the JTabbedPane dynamically. To add tabs to this builder use the tab object returned by tab(String) like so:
      
            UI.tabbedPane(vm.getSelectionIndex())
            .add(UI.tab("First").add(UI.panel().add(..)))
            .add(UI.tab("second").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("third").withIcon(someIcon).add(UI.button("click me")))
        
      Note that contrary to method tabbedPane(Var), this method receives a Val property which may not be changed by the GUI user. If you want to allow the user to change the selection index property state, use tabbedPane(Var) instead.
      Parameters:
      selectedIndex - The index of the tab to select.
      Returns:
      A builder instance wrapping a new JTabbedPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if selectedIndex is null.
    • tabbedPane

      public static UIForTabbedPane<JTabbedPane> tabbedPane(sprouts.Var<Integer> selectedIndex)
      Use this to create a builder for a new JTabbedPane UI component with the provided selectedIndex property which should determine the tab selection of the JTabbedPane dynamically. To add tabs to this builder use the tab object returned by tab(String) like so:
      
            UI.tabbedPane(vm.getSelectionIndex())
            .add(UI.tab("First").add(UI.panel().add(..)))
            .add(UI.tab("second").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("third").withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      selectedIndex - The index of the tab to select.
      Returns:
      A builder instance wrapping a new JTabbedPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if selectedIndex is null.
    • tab

      public static Tab tab(String title)
      Use this to add tabs to a JTabbedPane by passing Tab instances to UIForTabbedPane builder like so:
      
            UI.tabbedPane()
            .add(UI.tab("First").add(UI.panel().add(..)))
            .add(UI.tab("second").withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab("third").withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      title - The text displayed on the tab button.
      Returns:
      A Tab instance containing everything needed to be added to a JTabbedPane.
      Throws:
      IllegalArgumentException - if title is null.
    • tab

      public static Tab tab(sprouts.Val<String> title)
      A factory method producing a Tab instance with the provided title property which can dynamically change the title of the tab button. Use this to add tabs to a JTabbedPane by passing Tab instances to UIForTabbedPane builder like so:
      
            UI.tabbedPane()
            .add(UI.tab(property1).add(UI.panel().add(..)))
            .add(UI.tab(property2).withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab(property3).withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      title - The text property dynamically changing the title of the tab button when the property changes.
      Returns:
      A Tab instance containing everything needed to be added to a JTabbedPane.
      Throws:
      IllegalArgumentException - if title is null.
    • tab

      public static Tab tab(JComponent component)
      Use this to add tabs to a JTabbedPane by passing Tab instances to UIForTabbedPane builder like so:
      
            UI.tabbedPane()
            .add(UI.tab(new JButton("X")).add(UI.panel().add(..)))
            .add(UI.tab(new JLabel("Hi!")).withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab(new JPanel()).add(UI.button("click me")))
        
      Parameters:
      component - The component displayed on the tab button.
      Returns:
      A Tab instance containing everything needed to be added to a JTabbedPane.
      Throws:
      IllegalArgumentException - if component is null.
    • tab

      public static Tab tab(UIForAnySwing<?,?> builder)
      Use this to add tabs to a JTabbedPane by passing Tab instances to UIForTabbedPane builder like so:
      
            UI.tabbedPane()
            .add(UI.tab(UI.button("X")).add(UI.panel().add(..)))
            .add(UI.tab(UI.label("Hi!")).withTip("I give info!").add(UI.label("read me")))
            .add(UI.tab(UI.of(...)).withIcon(someIcon).add(UI.button("click me")))
        
      Parameters:
      builder - The builder wrapping the component displayed on the tab button.
      Returns:
      A Tab instance containing everything needed to be added to a JTabbedPane.
      Throws:
      IllegalArgumentException - if builder is null.
    • of

      public static <M extends JMenu> UIForMenu<M> of(M component)
      Use this to create a builder for the provided JMenu instance.
      Type Parameters:
      M - The concrete type of the menu.
      Parameters:
      component - The JMenu component which should be wrapped by the swing tree UI builder designed for menus.
      Returns:
      A builder instance for the provided JMenu, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • of

      public static <M extends JMenuItem> UIForMenuItem<M> of(M component)
      Use this to create a builder for the provided JMenuItem instance.
      Type Parameters:
      M - The type parameter of the concrete menu item component.
      Parameters:
      component - The JMenuItem component which should be wrapped by the swing tree UI builder designed for menu items.
      Returns:
      A builder instance for the provided JMenuItem, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • of

      public static <M extends JRadioButtonMenuItem> UIForRadioButtonMenuItem<M> of(M radioMenuItem)
      A factory method to wrap the provided JRadioButtonMenuItem instance in a SwingTree UI builder.
      Type Parameters:
      M - The type of the JRadioButtonMenuItem instance to be wrapped.
      Parameters:
      radioMenuItem - The JRadioButtonMenuItem instance to be wrapped.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem()
      A factory method to create a plain JRadioButtonMenuItem instance.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.radioButtonMenuItem().onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem().onClick( it -> {..} ))
        
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(String text)
      A factory method to create a JRadioButtonMenuItem with the provided text displayed on the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.radioButtonMenuItem("Delete").onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem("Edit").onClick( it -> {..} ))
       
      Parameters:
      text - The text which should be displayed on the wrapped JRadioButtonMenuItem.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(sprouts.Val<String> text)
      A factory method to create a JRadioButtonMenuItem bound to the provided text property, whose value will be displayed on the menu button dynamically.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.radioButtonMenuItem(Val.of("Delete")).onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem(Val.of("Edit")).onClick( it -> {..} ))
       
      Note that in a real application you would take the text property from a model object through a plain old getter method (e.g. myViewModel.getTextProperty()).
      Parameters:
      text - The text property which should be displayed on the wrapped JRadioButtonMenuItem dynamically.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(String text, Icon icon)
      A factory method to create a JRadioButtonMenuItem with the provided text displayed on the menu button and the provided icon displayed on the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.radioButtonMenuItem("Delete", UI.icon("delete.png")).onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem("Edit", UI.icon("edit.png")).onClick( it -> {..} ))
       
      Parameters:
      text - The text which should be displayed on the wrapped JRadioButtonMenuItem.
      icon - The icon which should be displayed on the wrapped JRadioButtonMenuItem.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(sprouts.Val<String> text, Icon icon)
      A factory method to create a JRadioButtonMenuItem bound to the provided text property, whose value will be displayed on the menu button dynamically and the provided icon displayed on the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.radioButtonMenuItem(Val.of("Delete"), UI.icon("delete.png")).onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem(Val.of("Edit"), UI.icon("edit.png")).onClick( it -> {..} ))
       
      Note that in a real application you would take the text property from a model object through a plain old getter method (e.g. myViewModel.getTextProperty()).
      Parameters:
      text - The text property which should be displayed on the wrapped JRadioButtonMenuItem dynamically.
      icon - The icon which should be displayed on the wrapped JRadioButtonMenuItem.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static <E extends Enum<E>> UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(E state, sprouts.Var<E> property)
      A factory method to create a JRadioButtonMenuItem bound to a fixed enum value and a variable enum property which will dynamically select the menu item based on the equality of the fixed enum value and the variable enum property value.
      Consider the following example code:
      
          UI.popupMenu()
          .add(UI.radioButtonMenuItem(Unit.SECONDS, myViewModel.unitProperty()))
          .add(UI.radioButtonMenuItem(Unit.MINUTES, myViewModel.unitProperty()))
          .add(UI.radioButtonMenuItem(Unit.HOURS,   myViewModel.unitProperty()))
        
      In this example the myViewModel.unitProperty() is a Var property of example type Unit. A given menu item will be selected if the value of the myViewModel.unitProperty() is equal to the first enum value passed to the factory method. This first enum will also be used as the text of the menu item through the toString().
      Type Parameters:
      E - The type of the enum.
      Parameters:
      state - The fixed enum value which will be used as the text of the menu item and
      property - The variable enum property which will be used to select the menu item.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if state or property are null.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(String text, sprouts.Var<Boolean> isSelected)
      A factory method to create a JRadioButtonMenuItem with some custom text and a boolean property, dynamically determining whether the radio button based menu item is selected or not.
      Here an example demonstrating the usage of this method:
      
          // inside your view model class:
          Var<Boolean> isSelected1 = Var.of(false);
          Var<Boolean> isSelected2 = Var.of(false);
          // inside your view class:
          UI.popupMenu()
          .add(UI.radioButtonMenuItem("Make Coffee", isSelected1).onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem("Make Tea", isSelected2).onClick( it -> {..} ))
       
      Note that in a real application you would take the boolean property from a model object through a plain old getter method (e.g. myViewModel.getIsSelectedProperty()).
      Parameters:
      text - The text which should be displayed on the wrapped JRadioButtonMenuItem.
      isSelected - The boolean property which will be bound to the menu item to dynamically determines whether the menu item is selected or not.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • radioButtonMenuItem

      public static UIForRadioButtonMenuItem<JRadioButtonMenuItem> radioButtonMenuItem(sprouts.Val<String> text, sprouts.Var<Boolean> isSelected)
      A factory method to create a JRadioButtonMenuItem with some custom text and a boolean property, dynamically determining whether the radio button based menu item is selected or not.
      Here an example demonstrating the usage of this method:
      
          // inside your view model class:
          Var<Boolean> isSelected1 = Var.of(false);
          Var<Boolean> isSelected2 = Var.of(false);
          // inside your view class:
          UI.popupMenu()
          .add(UI.radioButtonMenuItem(Val.of("Make Coffee"), isSelected1).onClick( it -> {..} ))
          .add(UI.radioButtonMenuItem(Val.of("Make Tea"), isSelected2).onClick( it -> {..} ))
       
      Note that in a real application you would take the String and boolean properties from a view model object through plain old getter methods (e.g. myViewModel.getTextProperty() and myViewModel.getIsSelectedProperty()).
      Parameters:
      text - The text property whose text should dynamically be displayed on the wrapped JRadioButtonMenuItem.
      isSelected - The boolean property which will be bound to the menu item to dynamically determines whether the menu item is selected or not.
      Returns:
      A builder instance for the provided JRadioButtonMenuItem, which enables fluent method chaining.
    • of

      public static <M extends JCheckBoxMenuItem> UIForCheckBoxMenuItem<M> of(M checkBoxMenuItem)
      A factory method to wrap the provided JCheckBoxMenuItem instance in a SwingTree UI builder.
      Type Parameters:
      M - The type of the JCheckBoxMenuItem instance to be wrapped.
      Parameters:
      checkBoxMenuItem - The JCheckBoxMenuItem instance to be wrapped.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem()
      A factory method to create a JCheckBoxMenuItem without text displayed on top of the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.checkBoxMenuItem().onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem().onClick( it -> {..} ))
       
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem(String text)
      A factory method to create a JCheckBoxMenuItem with the provided text displayed on the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.checkBoxMenuItem("Delete").onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem("Edit").onClick( it -> {..} ))
       
      Parameters:
      text - The text which should be displayed on the wrapped JCheckBoxMenuItem.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem(sprouts.Val<String> text)
      A factory method to create a JCheckBoxMenuItem bound to the provided text property, whose value will be displayed on the menu button dynamically.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.checkBoxMenuItem(Val.of("Delete")).onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem(Val.of("Edit")).onClick( it -> {..} ))
       
      Note that in a real application you would take the text property from a model object through a plain old getter method (e.g. myViewModel.getTextProperty()).
      Parameters:
      text - The text property which should be displayed on the wrapped JCheckBoxMenuItem dynamically.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem(String text, Icon icon)
      A factory method to create a JCheckBoxMenuItem with the provided text displayed on the menu button and the provided icon displayed on the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.checkBoxMenuItem("Delete", UI.icon("delete.png")).onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem("Edit", UI.icon("edit.png")).onClick( it -> {..} ))
       
      Parameters:
      text - The text which should be displayed on the wrapped JCheckBoxMenuItem.
      icon - The icon which should be displayed on the wrapped JCheckBoxMenuItem.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem(String text, sprouts.Var<Boolean> isSelected)
      A factory method to create a JCheckBoxMenuItem with some custom text and a boolean property, dynamically determining whether the menu item is selected or not.
      Here an example demonstrating the usage of this method:
      
          // inside your view model class:
          Var<Boolean> isSelected = Var.of(false);
          // inside your view class:
          UI.popupMenu()
          .add(UI.checkBoxMenuItem("Delete", isSelected).onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem("Edit", isSelected).onClick( it -> {..} ))
       
      Note that in a real application you would take the boolean property from a model object through a plain old getter method (e.g. myViewModel.getIsSelectedProperty()).
      Parameters:
      text - The text which should be displayed on the wrapped JCheckBoxMenuItem.
      isSelected - The boolean property which will be bound to the menu item to dynamically determines whether the menu item is selected or not.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem(sprouts.Val<String> text, Icon icon)
      A factory method to create a JCheckBoxMenuItem bound to the provided text property, whose value will be displayed on the menu button dynamically and the provided icon displayed on the menu button.
      Here an example demonstrating the usage of this method:
      
          UI.popupMenu()
          .add(UI.checkBoxMenuItem(Val.of("Delete"), UI.icon("delete.png")).onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem(Val.of("Edit"), UI.icon("edit.png")).onClick( it -> {..} ))
       
      Note that in a real application you would take the text property from a model object through a plain old getter method (e.g. myViewModel.getTextProperty()).
      Parameters:
      text - The text property which should be displayed on the wrapped JCheckBoxMenuItem dynamically.
      icon - The icon which should be displayed on the wrapped JCheckBoxMenuItem.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • checkBoxMenuItem

      public static UIForCheckBoxMenuItem<JCheckBoxMenuItem> checkBoxMenuItem(sprouts.Val<String> text, sprouts.Var<Boolean> isSelected)
      A factory method to create a JCheckBoxMenuItem bound to the provided text property, whose value will be displayed on the menu button dynamically and the provided boolean property, dynamically determining whether the menu item is selected or not.
      Here an example demonstrating the usage of this method:
      
          // inside your view model class:
          Var<Boolean> isSelected = Var.of(false);
          // inside your view class:
          UI.popupMenu()
          .add(UI.checkBoxMenuItem(Val.of("Delete"), isSelected).onClick( it -> {..} ))
          .add(UI.checkBoxMenuItem(Val.of("Edit"), isSelected).onClick( it -> {..} ))
       
      Note that in a real application you would take the text property from a model object through a plain old getter method (e.g. myViewModel.getTextProperty()).
      Parameters:
      text - The text property which should be displayed on the wrapped JCheckBoxMenuItem dynamically.
      isSelected - The boolean property which will be bound to the menu item to dynamically determines whether the menu item is selected or not.
      Returns:
      A builder instance for the provided JCheckBoxMenuItem, which enables fluent method chaining.
    • of

      public static <T extends JToolBar> UIForToolBar<T> of(T component)
      Use this to create a builder for the provided JToolBar instance. Using method chaining you can populate the JToolBar by like so:
      
          UI.of(myToolBar)
          .add(UI.button("X"))
          .add(UI.button("Y"))
          .add(UI.button("Z"))
          .addSeparator()
          .add(UI.button("A"))
        

      Type Parameters:
      T - The type of the JToolBar instance to be wrapped.
      Parameters:
      component - The JToolBar instance to be wrapped.
      Returns:
      A builder instance for the provided JToolBar, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • toolBar

      public static UIForToolBar<JToolBar> toolBar()
      Use this to create a builder for a new JToolBar instance. Use method chaining to add buttons or other components to a JToolBar by passing them to UIForToolBar builder like so:
      
          UI.toolBar()
          .add(UI.button("X"))
          .add(UI.button("Y"))
          .add(UI.button("Z"))
          .addSeparator()
          .add(UI.button("A"))
        

      Returns:
      A builder instance for the provided JToolBar, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • toolBar

      public static UIForToolBar<JToolBar> toolBar(UI.Align align)
      A factory method for creating a JToolBar instance where the provided UI.Align enum defines the orientation of the JToolBar.
      Parameters:
      align - The UI.Align enum which defines the orientation of the JToolBar.
      Returns:
      A builder instance for the provided JToolBar, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
    • toolBar

      public static UIForToolBar<JToolBar> toolBar(sprouts.Val<UI.Align> align)
      A factory method for creating a JToolBar instance where the provided Val property dynamically defines the orientation of the JToolBar
      Parameters:
      align - The Val property which dynamically defines the orientation of the JToolBar.
      Returns:
      A builder instance for the provided JToolBar, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
    • of

      public static <P extends JScrollPane> UIForScrollPane<P> of(P component)
      Use this to create a builder for the provided JScrollPane component.
      Type Parameters:
      P - The type parameter defining the concrete scroll pane type.
      Parameters:
      component - The JScrollPane component which should be represented by the returned builder.
      Returns:
      A UIForScrollPane builder representing the provided component.
      Throws:
      IllegalArgumentException - if component is null.
    • scrollPane

      public static UIForScrollPane<JScrollPane> scrollPane()
      Use this to create a builder for a new JScrollPane UI component. This is in essence a convenience method for UI.of(new JScrollPane()).
      Here is an example of a simple scroll panel with a text area inside:
      
            UI.scrollPane()
            .withScrollBarPolicy(UI.Scroll.NEVER)
            .add(UI.textArea("I am a text area with this text inside."))
        
      Returns:
      A builder instance for a new JScrollPane, which enables fluent method chaining.
    • of

      public static <P extends JScrollPanels> UIForScrollPanels<P> of(P component)
      Use this to create a builder for the provided JScrollPanels component.
      Type Parameters:
      P - The type parameter defining the concrete scroll panels type.
      Parameters:
      component - The JScrollPanels component which should be represented by the returned builder.
      Returns:
      A UIForScrollPanels builder representing the provided component.
      Throws:
      IllegalArgumentException - if component is null.
    • scrollPanels

      public static UIForScrollPanels<JScrollPanels> scrollPanels()
      Use this to create a builder for a new JScrollPanels UI component. This is in essence a convenience method for UI.of(new JScrollPanels()).
      Here is an example of a simple scroll panel with a text area inside:
      
            UI.scrollPanels()
            .withScrollBarPolicy(UI.Scroll.NEVER)
            .add(UI.textArea("I am a text area with this text inside."))
            .add(UI.label("I am a label!"))
            .add(UI.button("I am a button! Click me!"))
        
      Returns:
      A builder instance for a new JScrollPanels, which enables fluent method chaining.
    • scrollPanels

      public static UIForScrollPanels<JScrollPanels> scrollPanels(UI.Align align)
      Use this to create a builder for a new JScrollPanels UI component. This is in essence a convenience method for UI.of(new JScrollPanels()).
      Here is an example of a simple scroll panel with a text area inside:
      
            UI.scrollPanels(Align.HORIZONTAL)
            .withScrollBarPolicy(UI.Scroll.NEVER)
            .add(UI.textArea("I am a text area with this text inside."))
            .add(UI.label("I am a label!"))
            .add(UI.button("I am a button! Click me!"))
        
      Parameters:
      align - The alignment of the scroll panels.
      Returns:
      A builder instance for a new JScrollPanels, which enables fluent method chaining.
    • scrollPanels

      public static UIForScrollPanels<JScrollPanels> scrollPanels(UI.Align align, Dimension size)
      Use this to create a builder for a new JScrollPanels UI component. This is in essence a convenience method for UI.of(new JScrollPanels()).
      Here is an example of a simple scroll panel with a text area inside:
      
            UI.scrollPanels(Align.HORIZONTAL, new Dimension(100,100))
            .withScrollBarPolicy(UI.Scroll.NEVER)
            .add(UI.textArea("I am a text area with this text inside."))
            .add(UI.label("I am a label!"))
            .add(UI.button("I am a button! Click me!"))
        
      Parameters:
      align - The alignment of the scroll panels.
      size - The size of the scroll panels.
      Returns:
      A builder instance for a new JScrollPanels, which enables fluent method chaining.
    • of

      public static <P extends JSplitPane> UIForSplitPane<P> of(P component)
      Use this to create a builder for the provided JSplitPane instance.
      Type Parameters:
      P - The type of the JSplitPane instance.
      Parameters:
      component - The JSplitPane instance to create a builder for.
      Returns:
      A builder instance for the provided JSplitPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • splitPane

      public static UIForSplitPane<JSplitPane> splitPane(UI.Align align)
      Use this to create a builder for a new JSplitPane instance based on the provided alignment enum determining how the split itself should be aligned.
      You can create a simple split pane based UI like so:
      
            UI.splitPane(UI.Align.HORIZONTAL) // The split bar will be horizontal
            .withDividerAt(50)
            .add(UI.panel().add(...)) // top
            .add(UI.scrollPane().add(...)) // bottom
        
      Parameters:
      align - The alignment determining if the JSplitPane split bar is aligned vertically or horizontally.
      Returns:
      A builder instance for the provided JSplitPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
    • splitPane

      public static UIForSplitPane<JSplitPane> splitPane(sprouts.Val<UI.Align> align)
      Use this to create a builder for a new JSplitPane instance based on the provided alignment property determining how the split itself should be aligned.
      You can create a simple split pane based UI like so:
      
          UI.splitPane(viewModel.getAlignment())
          .withDividerAt(50)
          .add(UI.panel().add(...)) // top
          .add(UI.scrollPane().add(...)) // bottom
        

      The split pane will be updated whenever the provided property changes.
      Note: The provided property must not be null! Otherwise, an IllegalArgumentException will be thrown.
      Parameters:
      align - The alignment determining if the JSplitPane split bar is aligned vertically or horizontally.
      Returns:
      A builder instance for the provided JSplitPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
    • of

      public static <P extends JEditorPane> UIForEditorPane<P> of(P component)
      Use this to create a builder for the provided JEditorPane instance.
      Type Parameters:
      P - The type of the JEditorPane instance.
      Parameters:
      component - The JEditorPane instance to create a builder for.
      Returns:
      A builder instance for the provided JEditorPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • editorPane

      public static UIForEditorPane<JEditorPane> editorPane()
      Use this to create a builder for a new JEditorPane UI component. This is in essence a convenience method for UI.of(new JEditorPane()).
      Returns:
      A builder instance for a new JEditorPane, which enables fluent method chaining.
    • of

      public static <P extends JTextPane> UIForTextPane<P> of(P component)
      Use this to create a builder for the provided JTextPane instance.
      Type Parameters:
      P - The type of the JTextPane instance.
      Parameters:
      component - The JTextPane instance to create a builder for.
      Returns:
      A builder instance for the provided JTextPane, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • textPane

      public static UIForTextPane<JTextPane> textPane()
      Use this to create a builder for a new JTextPane UI component. This is in essence a convenience method for UI.of(new JTextPane()).
      Returns:
      A builder instance for a new JTextPane, which enables fluent method chaining.
    • of

      public static <S extends JSlider> UIForSlider<S> of(S component)
      Use this to create a builder for the provided JSlider instance.
      Type Parameters:
      S - The type of the JSlider instance.
      Parameters:
      component - The JSlider instance to create a builder for.
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • slider

      public static UIForSlider<JSlider> slider(UI.Align align)
      Use this to create a builder for a new JSlider instance based on tbe provided alignment type determining if the slider will be aligned vertically or horizontally.
      Parameters:
      align - The alignment determining if the JSlider aligns vertically or horizontally.
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
      See Also:
    • slider

      public static UIForSlider<JSlider> slider(sprouts.Val<UI.Align> align)
      Use this to create a builder for a new JSlider instance based on the provided alignment property which dynamically determines if the property is aligned vertically or horizontally.
      Parameters:
      align - The alignment property determining if the JSlider aligns vertically or horizontally.
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if the align property is null.
      See Also:
    • slider

      public static UIForSlider<JSlider> slider(UI.Align align, int min, int max)
      Use this to create a builder for a new JSlider instance based on tbe provided alignment type, min slider value and max slider value.
      Parameters:
      align - The alignment determining if the JSlider aligns vertically or horizontally.
      min - The minimum possible value of the slider.
      max - The maximum possible value of the slider.
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
      See Also:
    • slider

      public static UIForSlider<JSlider> slider(UI.Align align, int min, int max, int value)
      Creates a slider with the specified alignment and the specified minimum, maximum, and initial values.
      Parameters:
      align - The alignment determining if the JSlider aligns vertically or horizontally.
      min - The minimum possible value of the slider.
      max - The maximum possible value of the slider.
      value - the initial value of the slider
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
      See Also:
    • slider

      public static UIForSlider<JSlider> slider(UI.Align align, int min, int max, sprouts.Val<Integer> value)
      Creates a slider with the specified alignment and the specified minimum, maximum, and dynamic value.
      The slider will be updated whenever the provided property changes. But note that the property is of the read only Val type, which means that when the user moves the slider, the property will not be updated.
      If you want bidirectional binding, use slider(UI.Align, int, int, Var) instead of this method.
      Parameters:
      align - The alignment determining if the JSlider aligns vertically or horizontally.
      min - The minimum possible value of the slider.
      max - The maximum possible value of the slider.
      value - The property holding the value of the slider
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
      See Also:
    • slider

      public static UIForSlider<JSlider> slider(UI.Align align, int min, int max, sprouts.Var<Integer> value)
      Creates a slider with the specified alignment and the specified minimum, maximum, and dynamic value property. The property will be updated whenever the user moves the slider and the slider will be updated whenever the property changes in your code (see Var.set(Object)).
      Parameters:
      align - The alignment determining if the JSlider aligns vertically or horizontally.
      min - The minimum possible value of the slider.
      max - The maximum possible value of the slider.
      value - The property holding the value of the slider
      Returns:
      A builder instance for the provided JSlider, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if align is null.
      See Also:
    • of

      public static <E, C extends JComboBox<E>> UIForCombo<E,C> of(C component)
      Use this to create a builder for the provided JComboBox instance.
      This is useful when you want to write declarative UI with a custom JComboBox type. Also see comboBox() for a more convenient way to create a new JComboBox instance.
      Type Parameters:
      E - The type of the elements in the JComboBox.
      C - The type of the JComboBox instance.
      Parameters:
      component - The JComboBox instance to create a builder for.
      Returns:
      A builder instance for the provided JComboBox, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox()
      Use this to create a UI builder for a the JComboBox component type. This is similar to UI.of(new JComboBox()).
      Type Parameters:
      E - The type of the elements in the JComboBox.
      Returns:
      A builder instance for a new JComboBox, which enables fluent method chaining.
    • comboBox

      @SafeVarargs public static <E> UIForCombo<E,JComboBox<E>> comboBox(E... items)
      Use this to declare a UI builder for the JComboBox component type with the provided array of elements as selectable items.
      Note that the user may modify the items in the provided array (if the combo box is editable), if you do not want that, consider using comboBoxWithUnmodifiable(Object[]) or comboBoxWithUnmodifiable(java.util.List).
      Type Parameters:
      E - The type of the elements in the JComboBox.
      Parameters:
      items - The array of elements to be selectable in the JComboBox.
      Returns:
      A builder instance for the new JComboBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(E[] items, Function<E,String> renderer)
      Use this create a UI declaration for the JComboBox component type with the provided array of elements as selectable items and a lambda function converting each item into a user-friendly String representation.
      Note that the user may modify the items in the provided array (if the combo box is editable), if you do not want that, consider using comboBoxWithUnmodifiable(Object[]) or comboBoxWithUnmodifiable(java.util.List).
      Type Parameters:
      E - The type of the elements in the JComboBox.
      Parameters:
      items - The array of elements to be selectable in the JComboBox.
      renderer - A lambda function which is used for mapping each entry to a user-friendly String representation.
      Returns:
      A builder instance for the new JComboBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • comboBoxWithUnmodifiable

      @SafeVarargs public static <E> UIForCombo<E,JComboBox<E>> comboBoxWithUnmodifiable(E... items)
      Use this to declare a UI builder for the JComboBox type with the provided array of elements as selectable items which may not be modified by the user.
      Type Parameters:
      E - The type of the elements in the JComboBox.
      Parameters:
      items - The unmodifiable array of elements to be selectable in the JList.
      Returns:
      A builder instance for the new JComboBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • comboBoxWithUnmodifiable

      public static <E> UIForCombo<E,JComboBox<E>> comboBoxWithUnmodifiable(E[] items, Function<E,String> renderer)
      Use this to declare a UI builder for the JComboBox type with the provided array of elements as selectable items which may not be modified by the user. Use this create a UI declaration for the JComboBox component type with the provided array of elements as selectable but unmodifiable items and a lambda function converting each item into a user-friendly String representation.
      Type Parameters:
      E - The type of the elements in the JComboBox.
      Parameters:
      items - The unmodifiable array of elements to be selectable in the drop down list of the combo box.
      Returns:
      A builder instance for the new JComboBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • comboBox

      public static <E extends Enum<E>> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selectedItem)
      Use this to create a builder for a new JComboBox instance where the provided enum based property dynamically models the selected item as well as all possible options (all the enum states). The property will be updated whenever the user selects a new item in the JComboBox and the JComboBox will be updated whenever the property changes in your code (see Var.set(Object)).
      Here's an example of how to use this method:
      
            // In your view model:
            enum Size { SMALL, MEDIUM, LARGE }
            private Var<Size> selection = Var.of(Size.SMALL);
      
            public Var<Size> selection() { return selection; }
      
            // In your view:
            UI.comboBox(vm.selection())
       

      Tip: The text displayed on the combo box is based on the Object.toString() method of the enum instances. If you want to customize how they are displayed (So that 'Size.LARGE' is displayed as 'Large' instead of 'LARGE') simply override the Object.toString() method in your enum.

      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      selectedItem - A property modelling the selected item in the combo box.
      Returns:
      A builder instance for the new JComboBox, which enables fluent method chaining.
    • comboBox

      public static <E extends Enum<E>> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selectedItem, Function<E,String> renderer)
      Use this to create a builder for a new JComboBox instance where the provided enum based property dynamically models the selected item as well as all possible options (all the enum states). The property will be updated whenever the user selects a new item in the JComboBox and the JComboBox will be updated whenever the property changes in your code (see Var.set(Object)).
      Here's an example of how to use this method:
      
            // In your view model:
            enum Size { SMALL, MEDIUM, LARGE }
            private Var<Size> selection = Var.of(Size.SMALL);
      
            public Var<Size> selection() { return selection; }
      
            // In your view:
            UI.comboBox(vm.selection(), e -> switch (e) {
                case SMALL -> "Small";
                case MEDIUM -> "Medium";
                case LARGE -> "Large";
            })
       

      Note that the second argument is a function that maps each enum state to the text which is actually displayed in the combo box to the user.

      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      selectedItem - A property modelling the selected item in the combo box.
      renderer - A lambda function which is used for mapping each entry to a user friendly String representation.
      Returns:
      A builder instance for the new JComboBox, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(List<E> items)
      Use this to declare a builder for a new JComboBox instance with the provided list of elements as selectable items.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The list of elements to be selectable in the JComboBox.
      Returns:
      A builder instance for the provided JComboBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(List<E> items, Function<E,String> renderer)
      Use this to declare a builder for a new JComboBox instance with the provided list of elements as selectable items and a custom renderer function to display the items in the combo box as text.
      Here's an example of how to use this method:
      
            // In your view model:
            List<String> items = List.of("Apple", "Banana", "Cherry");
            // In your view:
            UI.comboBox(items, fruit -> fruit.toUpperCase())
        
      In this example, the combo box will display the items as "APPLE", "BANANA", "CHERRY". The provided function is called for each item in the list to determine the text that should be displayed in the combo box.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The list of elements to be selectable in the JComboBox.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A builder instance for the JComboBox type, to allow for fluent method chaining.
    • comboBoxWithUnmodifiable

      public static <E> UIForCombo<E,JComboBox<E>> comboBoxWithUnmodifiable(List<E> items)
      Use this to create a builder for a new JComboBox instance with the provided UI.List of elements as selectable items which may not be modified by the user.
      So even if the combo box is editable, the user will not be able to modify the items in the list (the selected item inside the text field can still be modified though).
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The list of elements to be selectable in the JComboBox.
      Returns:
      A UI builder for the provided JComboBox, which enables fluent method chaining.
    • comboBoxWithUnmodifiable

      public static <E> UIForCombo<E,JComboBox<E>> comboBoxWithUnmodifiable(List<E> items, Function<E,String> renderer)
      Creates a declarative combo box UI based on the provided list of items, which may not be modified by the user.
      An additional renderer function is provided to customize how the items are displayed as texts in the combo box.
      Here's an example of how the method may be used:
      
            // In your view model:
            List<String> items = List.of("John", "Jane", "Jack");
            // In your view:
            UI.comboBoxWithUnmodifiable(items, name -> name.toLowerCase())
        
      In this example, the combo box will display the items as "john", "jane", "jack". The provided function is called for each item in the list to determine the text that should be displayed in the combo box.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The list of elements to be selectable in the JComboBox.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A builder instance for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selection, List<E> items)
      Creates a combo box UI builder node with a Var property as the model for the current selection and a list of items as a dynamically sized model for the selectable items.

      Note that the provided list may be mutated by the combo box UI component

      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The property holding the current selection.
      items - The list of selectable items.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selection, List<E> items, Function<E,String> renderer)
      Creates a declarative combo box UI based on the provided selection property and the list of items as well as a custom renderer function to display the items as text in the combo box.
      Here's an example of how the method can be used:
      
            // In your view model:
            List<String> days = List.of("Monday", "Tuesday", "Wednesday");
            Var<String> selectedDay = Var.of("Monday");
            // In your view:
            UI.comboBox(selectedDay, days, day -> "Day: " + day)
            // The combo box will display the items as "Day: Monday", "Day: Tuesday", "Day: Wednesday"
        
      In this example, the provided function is called for each item in the list to determine the text that should be displayed in the combo box.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The property holding the current selection, which will be updated whenever the user selects a new item.
      items - The list of selectable items.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A builder instance for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Vars<E> items)
      Use this to create a builder for a new JComboBox instance with the provided properties list object as selectable (and mutable) items.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The Vars properties of elements to be selectable in the JComboBox.
      Returns:
      A declarative builder for the provided JComboBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Vars<E> items, Function<E,String> renderer)
      Creates a declarative UI builder for the JComboBox component type where the provided property list dynamically models the selectable items in the combo box and a renderer function determines how the items are displayed as text in the combo box dropdown list.
      The following example demonstrates how this method may be used:
      
          // In your view model:
          enum Coffee { ESPRESSO, LATTE, CAPPUCCINO }
          Vars<Coffee> items = Vars.of(Coffee.ESPRESSO,
                                       Coffee.LATTE,
                                       Coffee.CAPPUCCINO);
          // In your view:
          UI.comboBox(items, coffee -> switch (coffee) {
            case ESPRESSO -> "Espresso";
            case LATTE -> "Latte";
            case CAPPUCCINO -> "Cappuccino";
          })
          .onSelection( it -> ... )
        
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The property holding the list of selectable items.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A declarative builder for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Vals<E> items)
      Use this to create a builder for a new JComboBox instance with the provided properties list object as selectable (and immutable) items which may not be modified by the user.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The Vals properties of elements to be selectable in the JComboBox.
      Returns:
      A builder instance for the provided JComboBox, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Vals<E> items, Function<E,String> renderer)
      Creates a declarative UI builder for the JComboBox component type where the provided property list dynamically models the selectable items in the combo box and a renderer function determines how the items are displayed as text in the combo box dropdown list.
      The following example demonstrates how this method may be used:
      
          // In your view model:
          enum Coffee { ESPRESSO, LATTE, CAPPUCCINO }
          Vals<Coffee> items = Vals.of(Coffee.ESPRESSO,
                                       Coffee.LATTE,
                                       Coffee.CAPPUCCINO);
          // In your view:
          UI.comboBox(items, coffee -> switch (coffee) {
            case ESPRESSO -> "Espresso";
            case LATTE -> "Latte";
            case CAPPUCCINO -> "Cappuccino";
          })
          .onSelection( it -> ... )
        
      Note that the provided list may not be modified by the user due to the use of the Vals property type, which is an immutable view of the list of items.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      items - The property holding the list of selectable items.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A declarative builder for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selection, sprouts.Vars<E> items)
      Creates a combo box UI builder node with a Var property as the model for the current selection and a list of items as a dynamically sized model for the selectable items.

      Note that the provided list may be mutated by the combo box UI component

      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The property holding the current selection.
      items - The list of selectable items.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selection, sprouts.Vars<E> items, Function<E,String> renderer)
      Creates a declarative combo box UI based on the provided selection property, a property list of selectable items as well as a custom renderer function to display the items as the desired text in the combo box.
      Here's an example of how the method can be used:
      
            // In your view model:
            enum Sentiment { POSITIVE, NEUTRAL, NEGATIVE }
            Var<Sentiment> selected = Var.of(Sentiment.NEUTRAL);
            Vars<Sentiment> sentiments = Vars.of(Sentiment.POSITIVE,
                                                 Sentiment.NEUTRAL,
                                                 Sentiment.NEGATIVE);
            // In your view:
            UI.comboBox(selected, sentiments, s -> switch (s) {
                case POSITIVE -> "Positive";
                case NEUTRAL -> "Neutral";
                case NEGATIVE -> "Negative";
            })
        
      In the example above, the provided function is called for each item in the list to determine the text that should be displayed in the combo box dropdown list.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The property holding the current selection, which will be updated whenever the user selects a new item.
      items - A property list of selectable items.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A declarative builder for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selection, sprouts.Vals<E> items)
      Creates a combo box UI builder node with a Var property as the model for the current selection and a property list of items as a dynamically sized model for the selectable items which may not be modified by the user. Use comboBox(Var, Vars) if you want the user to be able to modify the items.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The property holding the current selection.
      items - The list of selectable items which may not be modified by the user.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selection, sprouts.Vals<E> items, Function<E,String> renderer)
      Creates a declarative combo box UI based on the provided selection property, a property list of selectable items as well as a custom renderer function to display the items as the desired text in the combo box.
      Here's an example of how the method can be used:
      
            // In your view model:
            enum BloodType { A, B, AB, O }
            Var<Sentiment> selected = Var.of(BloodType.A);
            Vals<Sentiment> types = Vals.of(BloodType.A,
                                            BloodType.B,
                                            BloodType.AB,
                                            BloodType.O);
            // In your view:
            UI.comboBox(selected, types, t -> switch (t) {
                case A -> "Type A";
                case B -> "Type B";
                case AB -> "Type AB";
                case O -> "Type O";
            })
        
      In the example above, the provided function is called for each item in the list to determine the text that should be displayed in the combo box dropdown list. Note that we are using the Vals property type to ensure the list of items is immutable and cannot be modified by the user. If you want the user to be able to modify the items, use comboBox(Var, Vars, Function).
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The property holding the current selection, which will be updated whenever the user selects a new item.
      items - A property list of selectable items which may not be modified by the user.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A declarative builder for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> var, E... items)
      Creates a combo box UI builder node with a Var property as the model for the current selection and an array of items as a fixed-size model for the selectable items.

      Note that the provided array may be mutated by the combo box UI component

      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      var - The property holding the current selection.
      items - The array of selectable items.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> var, E[] items, Function<E,String> renderer)
      Creates a combo box UI declaration with a Var property as the model for the current selection and an array of items as a fixed-size model for the selectable items, as well as a lambda function which maps each combo box item to a user-friendly String representation.

      Note that the provided array may be mutated by the combo box UI component.

      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      var - The property holding the current selection.
      items - The array of selectable items.
      renderer - A function that maps each item to the text that should be displayed in the combo box. It is intended to make the type of entry more human readable and thereby user-friendly.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> var, sprouts.Var<E[]> items)
      Creates a combo box UI builder node with a Var property as the model for the current selection and an array property of items as a selectable items model of variable length.

      Note that the provided array may be mutated by the combo box UI component

      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      var - The property holding the current selection.
      items - The property holding an array of selectable items which can be mutated by the combo box.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> var, sprouts.Var<E[]> items, Function<E,String> renderer)
      Creates a declarative combo box UI based on the provided selection property, a property of an array of selectable items and a custom renderer function to display the items as the desired text in the combo box.
      Here's an example of how the method can be used:
      
            // In your view model:
            enum Cost { CHEAP, MODERATE, EXPENSIVE }
            Var<Cost> selected = Var.of(Cost.CHEAP);
            Var<Cost[]> costs = Var.of(Cost.values());
            // In your view:
            UI.comboBox(selected, costs, c -> switch (c) {
                case CHEAP -> "Cheap";
                case MODERATE -> "Moderate";
                case EXPENSIVE -> "Expensive";
            })
        
      In the example above, the provided function is called for each item in the list to determine the text that should be displayed in the combo box dropdown list. Note that changing the contents of the array in the property may not properly update the selectable options in the combo box. Instead, ensure that the Var.set(Object), or Val.fireChange(Channel) method is used to update the available options in the combo box.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      var - The property holding the current selection, which will be updated whenever the user selects a new item.
      items - A property array of selectable items which can be mutated by the user.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A declarative builder for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selectedItem, sprouts.Val<E[]> items)
      Creates a combo box UI builder node with a Var property as the model for the current selection and an array property of items as a selectable items model of variable length.

      Note that the provided array may be mutated by the combo box UI component

      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      selectedItem - The property holding the current selection.
      items - The property holding an array of selectable items which may not be modified by the user.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(sprouts.Var<E> selectedItem, sprouts.Val<E[]> items, Function<E,String> renderer)
      Creates a declarative combo box UI based on the provided selection property, a property of an array of selectable items and a custom renderer function to display the items as the desired text in the combo box.
      Here's an example of how the method can be used:
      
            // In your view model:
            enum Vehicle { TRAIN, BIKE, BUS }
            Var<Vehicle> selected = Var.of(Vehicle.BIKE);
            Val<Vehicle[]> vehicles = Val.of(Vehicle.values());
            // In your view:
            UI.comboBox(selected, vehicles, v -> switch (v) {
                case TRAIN -> "Train";
                case BIKE -> "Bike";
                case BUS -> "Bus";
            })
        
      In this example the provided function is called for each item in the list to determine the text that should be displayed in the combo box dropdown list. Note that changing the contents of the array in the property may not properly update the selectable options in the combo box. Instead, ensure that the Var.set(Object), or Val.fireChange(Channel) method is used to update the available options in the combo box.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selectedItem - The property holding the current selection, which will be updated whenever the user selects a new item.
      items - A property array of selectable items which may not be modified by the user.
      renderer - A function that maps each item to the text that should be displayed in the combo box.
      Returns:
      A declarative builder for the JComboBox type, to allow for fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(ComboBoxModel<E> model)
      Created a combo box UI builder node with the provided ComboBoxModel.
      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      model - The model to be used by the combo box.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • comboBox

      public static <E> UIForCombo<E,JComboBox<E>> comboBox(ComboBoxModel<E> model, Function<E,String> renderer)
      Created a combo box UI builder node with the provided ComboBoxModel and a lambda function mapping each model entry to a user-friendly human-readable String representation.
      Type Parameters:
      E - The type of the elements in the combo box.
      Parameters:
      model - The model to be used by the combo box.
      renderer - A function that maps each item to the text that should be displayed in the combo box. It is intended to make the type of entry more human-readable and thereby user-friendly.
      Returns:
      A builder instance for the provided JList, which enables fluent method chaining.
    • of

      public static <S extends JSpinner> UIForSpinner<S> of(S spinner)
      Use this to create a builder for the provided JSpinner instance.
      Type Parameters:
      S - The type parameter of the concrete JSpinner subclass to be used by the builder.
      Parameters:
      spinner - The JSpinner instance to create a builder for. The provided JSpinner instance must not be null.
      Returns:
      A builder instance for the provided JSpinner, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if spinner is null.
    • spinner

      public static UIForSpinner<JSpinner> spinner()
      Use this to create a builder for a new JSpinner UI component. This is in essence a convenience method for UI.of(new JSpinner()).
      Returns:
      A builder instance for a new JSpinner, which enables fluent method chaining.
    • spinner

      public static UIForSpinner<JSpinner> spinner(SpinnerModel model)
      Use this to create a builder for the provided JSpinner instance with the provided SpinnerModel as the model.
      Parameters:
      model - The SpinnerModel to be used by the JSpinner.
      Returns:
      A builder instance for the provided JSpinner, which enables fluent method chaining.
    • spinner

      public static UIForSpinner<JSpinner> spinner(sprouts.Var<?> value)
      Use this factory method to create a JSpinner bound to a property of any type. The property will be updated when the user modifies its value.
      Parameters:
      value - A property of any type which should be bound to this spinner.
      Returns:
      A builder instance for the provided JSpinner, which enables fluent method chaining.
    • spinner

      public static UIForSpinner<JSpinner> spinner(int value, int min, int max, int step)
      Use this to create a builder for the provided JSpinner instance with the provided min, max, default value and step as the model.
      Parameters:
      value - The default value of the JSpinner.
      min - The minimum possible value of the JSpinner.
      max - The maximum possible value of the JSpinner.
      step - The step size of the JSpinner.
      Returns:
      A builder instance for the provided JSpinner, which enables fluent method chaining.
    • spinner

      public static UIForSpinner<JSpinner> spinner(int value, int min, int max)
      Use this to create a builder for the provided JSpinner instance with the provided min, max and default value as the model.
      Parameters:
      value - The default value of the JSpinner.
      min - The minimum possible value of the JSpinner.
      max - The maximum possible value of the JSpinner.
      Returns:
      A builder instance for the provided JSpinner, which enables fluent method chaining.
    • of

      public static <L extends JLabel> UIForLabel<L> of(L label)
      Use this to create a builder for the provided JLabel instance.
      Type Parameters:
      L - The type parameter of the concrete JLabel subclass to be used by the builder.
      Parameters:
      label - The JLabel instance to be used by the builder.
      Returns:
      A builder instance for the provided JLabel, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(String text)
      Use this to create a builder for the JLabel UI component. This is in essence a convenience method for UI.of(new JLabel(text).
      Parameters:
      text - The text which should be displayed on the label.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(String text, UI.HorizontalAlignment alignment)
      Use this to create a builder for the JLabel UI component. This is in essence a convenience method for UI.of(new JLabel(text, alignment)).
      Parameters:
      text - The text which should be displayed on the label.
      alignment - The horizontal alignment of the text.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(String text, UI.Alignment alignment)
      Use this to create a builder for the JLabel UI component.
      Parameters:
      text - The text which should be displayed on the label.
      alignment - The vertical and horizontal alignment of the text.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(sprouts.Val<String> text)
      Use this to create a builder for the JLabel UI component. This is in essence a convenience method for UI.of(new JLabel(Val<String> text).
      Parameters:
      text - The text property which should be bound to the label.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(sprouts.Val<String> text, UI.HorizontalAlignment alignment)
      Use this to create a builder for the JLabel UI component. This is in essence a convenience method for UI.of(new JLabel(Val<String> text, alignment).
      Parameters:
      text - The text property which should be bound to the label.
      alignment - The horizontal alignment of the text.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(Icon icon)
      Use this to create a UI builder for a text-less label containing and displaying an icon.
      Parameters:
      icon - The icon which should be placed into a JLabel.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(IconDeclaration icon)
      Use this to create a UI builder for a text-less label containing and displaying an icon. The icon is specified by a IconDeclaration which is essentially just a path to an icon resource. If the icon cannot be found, the label will be empty. Note that loaded icons are cached, so if you load the same icon multiple times, the same icon instance will be used (see SwingTree.getIconCache()).
      Parameters:
      icon - The icon which should be placed into a JLabel.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • labelWithIcon

      public static UIForLabel<JLabel> labelWithIcon(sprouts.Val<IconDeclaration> icon)
      Use this to create a UI builder for a text-less label containing and displaying an icon dynamically.

      But note that you may not use the Icon or ImageIcon classes directly, instead you must use implementations of the IconDeclaration interface, which merely models the resource location of the icon, but does not load the whole icon itself.

      The reason for this distinction is the fact that traditional Swing icons are heavy objects whose loading may or may not succeed, and so they are not suitable for direct use in a property as part of your view model. Instead, you should use the IconDeclaration interface, which is a lightweight value object that merely models the resource location of the icon even if it is not yet loaded or even does not exist at all.

      This is especially useful in case of unit tests for you view model, where the icon may not be available at all, but you still want to test the behaviour of your view model.

      Parameters:
      icon - The icon property which should dynamically provide a desired icon for the JLabel.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(int width, int height, ImageIcon icon)
      Use this to create a UI builder for a text-less label containing and displaying an icon.
      Parameters:
      width - The width of the icon when displayed on the label.
      height - The height of the icon when displayed on the label.
      icon - The icon which should be placed into a JLabel.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • label

      public static UIForLabel<JLabel> label(int width, int height, IconDeclaration icon)
      Use this to create a UI builder for a text-less label containing and displaying an icon. The icon is specified by a IconDeclaration which is essentially just a path to an icon resource. If the icon cannot be found, the label will be empty. Note that loaded icons are cached, so if you load the same icon multiple times, the same icon instance will be used (see SwingTree.getIconCache()).
      Parameters:
      width - The width of the icon when displayed on the label.
      height - The height of the icon when displayed on the label.
      icon - The icon which should be placed into a JLabel.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • boldLabel

      public static UIForLabel<JLabel> boldLabel(String text)
      Use this to create a UI builder for a JLabel with bold font. This is in essence a convenience method for UI.label(String text).makeBold().
      Parameters:
      text - The text which should be displayed on the label.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • boldLabel

      public static UIForLabel<JLabel> boldLabel(sprouts.Val<String> text)
      Use this to create a UI builder for a bound JLabel with bold font. This is in essence a convenience method for UI.label(Val<String> text).makeBold().
      Parameters:
      text - The text property which should be displayed on the label dynamically.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • html

      public static UIForLabel<JLabel> html(String text)
      Use this to create a builder for a JLabel displaying HTML. This is in essence a convenience method for UI.of(new JLabel("<html>" + text + "</html>")).
      Parameters:
      text - The html text which should be displayed on the label.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • html

      public static UIForLabel<JLabel> html(sprouts.Val<String> text)
      Use this to create a builder for a JLabel displaying HTML. This is in essence a convenience method for UI.of(new JLabel("<html>" + text + "</html>")).
      Parameters:
      text - The html text property which should be bound to the label.
      Returns:
      A builder instance for the label, which enables fluent method chaining.
    • of

      public static <I extends JIcon> UIForIcon<I> of(I icon)
      Use this to create a builder for the provided JIcon instance.
      Type Parameters:
      I - The type of the JIcon instance.
      Parameters:
      icon - The JIcon instance to be used by the builder.
      Returns:
      A builder instance for the provided JIcon, which enables fluent method chaining.
    • icon

      public static UIForIcon<JIcon> icon(Icon icon)
      Creates a builder node wrapping a new JIcon instance with the provided icon displayed on it.
      Parameters:
      icon - The icon which should be displayed on the JIcon.
      Returns:
      A builder instance for the icon, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided icon is null.
    • icon

      public static UIForIcon<JIcon> icon(IconDeclaration icon)
      Creates a builder node wrapping a new JIcon instance with the icon found at the path provided by the supplied IconDeclaration displayed on it. Note that the icon will be cached by the JIcon instance, so that it will not be reloaded.
      Parameters:
      icon - The icon which should be displayed on the JIcon.
      Returns:
      A builder instance for the icon, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided icon is null.
    • icon

      public static UIForIcon<JIcon> icon(int width, int height, Icon icon)
      Creates a builder node wrapping a new JIcon instance with the provided icon scaled to the provided width and height.
      Parameters:
      width - The width of the icon when displayed on the JIcon.
      height - The height of the icon when displayed on the JIcon.
      icon - The icon which should be placed into a JIcon for display.
      Returns:
      A builder instance for the icon, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided icon is null.
    • icon

      public static UIForIcon<JIcon> icon(int width, int height, IconDeclaration icon)
      Creates a builder node wrapping a new JIcon instance with the icon found at the path defined by the supplied IconDeclaration displayed on it and scaled to the provided width and height. Note that the icon will be cached by the JIcon instance, so that it will not be reloaded.
      Parameters:
      width - The width of the icon when displayed on the JIcon.
      height - The height of the icon when displayed on the JIcon.
      icon - The icon which should be placed into a JIcon for display.
      Returns:
      A builder instance for the icon, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided icon is null.
    • icon

      public static UIForIcon<JIcon> icon(int width, int height, String iconPath)
      Creates a builder node wrapping a new JIcon instance with the icon found at the provided path displayed on it and scaled to the provided width and height. Note that the icon will be cached by the JIcon instance, so that it will not be reloaded.
      Parameters:
      width - The width of the icon when displayed on the JIcon.
      height - The height of the icon when displayed on the JIcon.
      iconPath - The path to the icon which should be displayed on the JIcon.
      Returns:
      A builder instance for the icon, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided icon path is null.
    • icon

      public static UIForIcon<JIcon> icon(String iconPath)
      Creates a builder node wrapping a new JIcon instance with the icon found at the provided path displayed on it. Note that the icon will be cached by the JIcon instance, so that it will not be reloaded.
      Parameters:
      iconPath - The path to the icon which should be displayed on the JIcon.
      Returns:
      A builder instance for the icon, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided icon path is null.
    • checkBox

      public static UIForCheckBox<JCheckBox> checkBox(String text)
      Creates a builder node wrapping a new JCheckBox instance with the provided text displayed on it.
      Parameters:
      text - The text which should be displayed on the checkbox.
      Returns:
      A builder instance for the checkbox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text is null.
    • checkBox

      public static UIForCheckBox<JCheckBox> checkBox(sprouts.Val<String> text)
      Creates a builder node wrapping a new JCheckBox instance where the provided text property dynamically displays its value on the checkbox.
      Parameters:
      text - The text property which should be bound to the checkbox.
      Returns:
      A builder instance for the checkbox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text property is null.
    • checkBox

      public static UIForCheckBox<JCheckBox> checkBox(sprouts.Val<String> text, sprouts.Var<Boolean> isChecked)
      Creates a builder node wrapping a new JCheckBox instance where the provided text property dynamically displays its value on the checkbox and the provided selection property dynamically determines whether the checkbox is selected or not.
      Parameters:
      text - The text property which should be bound to the checkbox. This is the text which is displayed on the checkbox.
      isChecked - The selection property which should be bound to the checkbox and determines whether it is selected or not.
      Returns:
      A builder instance for the checkbox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text property is null.
    • checkBox

      public static UIForCheckBox<JCheckBox> checkBox(String text, sprouts.Var<Boolean> isChecked)
      Creates a builder node wrapping a new JCheckBox instance with the provided text displayed on it and the provided selection property dynamically determining whether the checkbox is selected or not.
      Parameters:
      text - The text which should be displayed on the checkbox.
      isChecked - The selection property which should be bound to the checkbox and determines whether it is selected or not.
      Returns:
      A builder instance for the checkbox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text is null.
    • of

      public static <B extends JCheckBox> UIForCheckBox<B> of(B component)
      Use this to create a builder for the provided JCheckBox instance.
      Type Parameters:
      B - The type parameter of the concrete JCheckBox subclass to be used by the builder.
      Parameters:
      component - The JCheckBox instance to be used by the builder.
      Returns:
      A builder instance for the provided JCheckBox, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided checkbox is null.
    • radioButton

      public static UIForRadioButton<JRadioButton> radioButton(String text)
      Creates a builder node wrapping a new JRadioButton instance with the provided text displayed on it.
      Parameters:
      text - The text which should be displayed on the radio button.
      Returns:
      A builder instance for the radio button, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text is null.
    • radioButton

      public static UIForRadioButton<JRadioButton> radioButton(sprouts.Val<String> text)
      Creates a builder node wrapping a new JRadioButton instance where the provided text property dynamically displays its value on the radio button.
      Parameters:
      text - The text property which should be bound to the radio button.
      Returns:
      A builder instance for the radio button, which enables fluent method chaining.
    • radioButton

      public static UIForRadioButton<JRadioButton> radioButton(sprouts.Val<String> text, sprouts.Var<Boolean> selected)
      Creates a builder node wrapping a new JRadioButton instance where the provided text property dynamically displays its value on the radio button and the provided selection property dynamically determines whether the radio button is selected or not.
      Parameters:
      text - The text property which should be bound to the radio button. This is the text which is displayed on the radio button.
      selected - The selection property which should be bound to the radio button and determines whether it is selected or not.
      Returns:
      A builder instance for the radio button, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text property is null.
    • radioButton

      public static UIForRadioButton<JRadioButton> radioButton(String text, sprouts.Var<Boolean> selected)
      Creates a builder node wrapping a new JRadioButton instance with the provided text displayed on it and the provided selection property dynamically determining whether the radio button is selected or not.
      Parameters:
      text - The text which should be displayed on the radio button.
      selected - The selection property which should be bound to the radio button and determines whether it is selected or not.
      Returns:
      A builder instance for the radio button, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text is null.
    • radioButton

      public static <E extends Enum<E>> UIForRadioButton<JRadioButton> radioButton(E state, sprouts.Var<E> selection)
      Creates a builder node wrapping a new JRadioButton instance dynamically bound to an enum based Var instance which will be used to dynamically model the selection state of the wrapped JToggleButton type by checking weather the property matches the provided enum or not.
      Here's an example of how to use this method:
      
            // In your view model:
            enum Size { SMALL, MEDIUM, LARGE }
            private Var<Size> selection = Var.of(Size.SMALL);
      
            public Var<Size> selection() { return selection; }
      
            // In your view:
            UI.panel()
            .add(UI.radioButton(Size.SMALL,  vm.selection())
            .add(UI.radioButton(Size.MEDIUM, vm.selection())
            .add(UI.radioButton(Size.LARGE,  vm.selection())
       

      Tip: For the text displayed on the radio buttons, the enums will be converted to strings using Object.toString() method. If you want to customize how they are displayed (So that 'Size.LARGE' is displayed as 'Large' instead of 'LARGE') simply override the Object.toString() method in your enum.

      Type Parameters:
      E - The type of the enum which this JToggleButton should represent.
      Parameters:
      state - The reference Enum which this JToggleButton should represent.
      selection - The Var instance which will be used to dynamically model the selection state of the wrapped JToggleButton type.
      Returns:
      A builder instance for the radio button, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if selected is null.
    • radioButton

      public static <T> UIForRadioButton<JRadioButton> radioButton(String label, T state, sprouts.Var<T> selection)
      Creates a declarative UI builder for the JRadioButton component type which is dynamically bound to the equality of the provided state and the provided selection property. This means that the radio button will be selected if the provided state is equal to the value of the provided selection property and deselected otherwise.
      A typical use case for this is to use an enum based property to model the selection state of the radio button like so:
      
          // In your view model:
          enum Size { SMALL, MEDIUM, LARGE }
          private Var<Size> selection = Var.of(Size.SMALL);
          public Var<Size> selection() { return selection; }
          // In your view:
          UI.panel()
          .add(UI.radioButton("Small", Size.SMALL, vm.selection())
          .add(UI.radioButton("Medium", Size.MEDIUM, vm.selection())
          .add(UI.radioButton("Large", Size.LARGE, vm.selection())
        
      Type Parameters:
      T - The type of the state object which this radio button should represent.
      Parameters:
      label - The text which should be displayed on the radio button.
      state - The reference object which this radio button should represent.
      selection - The property which will be used to model the selection state of the radio button.
      Returns:
      A builder instance for the radio button, which enables fluent method chaining.
    • of

      public static <R extends JRadioButton> UIForRadioButton<R> of(R component)
      Use this to create a builder for the provided JRadioButton instance.
      Type Parameters:
      R - The type of the JRadioButton instance which should be wrapped by the builder.
      Parameters:
      component - The JRadioButton instance which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JRadioButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton()
      Use this to create a builder for a JToggleButton instance.
      Returns:
      A builder instance for a new JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(String text)
      Use this to create a builder for a new JToggleButton instance with the provided text displayed on it.
      Parameters:
      text - The text which should be displayed on the toggle button.
      Returns:
      A builder instance for a new JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(sprouts.Val<String> text)
      Use this to create a builder for a new JToggleButton instance where the provided text property dynamically displays its value on the toggle button.

      Note that the provided text property may not be null, and it is also not permitted to contain null values, instead use an empty string instead of null.

      Parameters:
      text - The text property which should be bound to the toggle button.
      Returns:
      A builder instance for a new JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(sprouts.Var<Boolean> isToggled)
      Use this to create a builder for a new JToggleButton instance where the provided boolean property dynamically determines whether the toggle button is selected or not.
      Parameters:
      isToggled - The boolean property which should be bound to the toggle button and determines whether it is selected or not.
      Returns:
      A builder instance for a new JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(String text, sprouts.Var<Boolean> isToggled)
      Use this to create a builder for a new JToggleButton instance with the provided text displayed on it and the provided boolean property dynamically determining whether the toggle button is selected or not.
      Parameters:
      text - The text which should be displayed on the toggle button.
      isToggled - The boolean property which should be bound to the toggle button and determines whether it is selected or not.
      Returns:
      A builder instance for a new JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(sprouts.Val<String> text, sprouts.Var<Boolean> isToggled)
      Use this to create a builder for a new JToggleButton instance where the provided text property dynamically displays its value on the toggle button and the provided boolean property dynamically determines whether the toggle button is selected or not.
      Parameters:
      text - The text property which should be bound to the toggle button. This is the text which is displayed on the toggle button.
      isToggled - The boolean property which should be bound to the toggle button and determines whether it is selected or not.
      Returns:
      A builder instance for a new JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(Icon icon)
      Use this to create a builder for a new JToggleButton instance with the provided Icon displayed on it.
      Parameters:
      icon - The icon which should be displayed on the toggle button.
      Returns:
      A builder instance for the provided JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(ImageIcon icon, UI.FitComponent fit)
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(int width, int height, ImageIcon icon)
      Use this to create a builder for the JToggleButton UI component with an icon displayed on it scaled according to the provided width and height.
      Parameters:
      width - The width the icon should be scaled to.
      height - The height the icon should be scaled to.
      icon - The icon to be displayed on top of the button.
      Returns:
      A builder instance for a JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(int width, int height, IconDeclaration icon)
      Use this to create a builder for the JToggleButton UI component with an icon displayed on it scaled according to the provided width and height.
      Parameters:
      width - The width the icon should be scaled to.
      height - The height the icon should be scaled to.
      icon - The IconDeclaration whose icon ought to be displayed on top of the button.
      Returns:
      A builder instance for a JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(int width, int height, IconDeclaration icon, UI.FitComponent fit)
      Creates a declarative toggle button builder for a JToggleButton displaying the provided icon scaled to fit the desired size and UI.FitComponent policy.
      Parameters:
      width - The width the icon should be scaled to.
      height - The height the icon should be scaled to.
      icon - The IconDeclaration whose icon ought to be displayed on top of the button.
      fit - The UI.FitComponent which determines how the icon should be fitted into the button.
      Returns:
      A builder instance for a JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(IconDeclaration icon)
      Use this to create a builder for a new JToggleButton instance with the icon found at the path provided by the supplied IconDeclaration displayed on top of it. Note that the icon will be cached by the JToggleButton instance, so that it will not be reloaded.
      Parameters:
      icon - The icon which should be displayed on the toggle button.
      Returns:
      A builder instance for the provided JToggleButton, which enables fluent method chaining.
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(IconDeclaration icon, UI.FitComponent fit)
    • toggleButton

      public static UIForToggleButton<JToggleButton> toggleButton(Icon icon, sprouts.Var<Boolean> isToggled)
      Use this to create a builder for a new JToggleButton instance with the provided Icon displayed on it and the provided boolean property dynamically determining whether the toggle button is selected or not.
      Parameters:
      icon - The icon which should be displayed on the toggle button.
      isToggled - The boolean property which should be bound to the toggle button and determines whether it is selected or not.
      Returns:
      A builder instance for the provided JToggleButton, which enables fluent method chaining.
    • toggleButtonWithIcon

      public static UIForToggleButton<JToggleButton> toggleButtonWithIcon(sprouts.Val<IconDeclaration> icon)
      Use this to create a builder for a new JToggleButton instance where the provided IconDeclaration based property dynamically displays the targeted image on the toggle button.

      Note that you may not use the Icon or ImageIcon classes directly, instead you must use implementations of the IconDeclaration interface, which merely models the resource location of the icon, but does not load the whole icon itself.

      The reason for this distinction is the fact that traditional Swing icons are heavy objects whose loading may or may not succeed, and so they are not suitable for direct use in a property as part of your view model. Instead, you should use the IconDeclaration interface, which is a lightweight value object that merely models the resource location of the icon even if it is not yet loaded or even does not exist at all.

      This is especially useful in case of unit tests for you view model, where the icon may not be available at all, but you still want to test the behaviour of your view model.

      Parameters:
      icon - The icon property which should be bound to the toggle button.
      Returns:
      A builder instance for the provided JToggleButton, which enables fluent method chaining.
    • toggleButtonWithIcon

      public static UIForToggleButton<JToggleButton> toggleButtonWithIcon(sprouts.Val<IconDeclaration> icon, sprouts.Var<Boolean> isToggled)
      Use this to create a builder for a new JToggleButton instance where the provided IconDeclaration property dynamically displays its targeted icon on the toggle button and the provided boolean property dynamically determines whether the toggle button is selected or not.

      But note that you may not use the Icon or ImageIcon classes directly, instead you must use implementations of the IconDeclaration interface, which merely models the resource location of the icon, but does not load the whole icon itself.

      The reason for this distinction is the fact that traditional Swing icons are heavy objects whose loading may or may not succeed, and so they are not suitable for direct use in a property as part of your view model. Instead, you should use the IconDeclaration interface, which is a lightweight value object that merely models the resource location of the icon even if it is not yet loaded or even does not exist at all.

      This is especially useful in case of unit tests for you view model, where the icon may not be available at all, but you still want to test the behaviour of your view model.

      Parameters:
      icon - The icon property which should be bound to the toggle button.
      isToggled - The boolean property which should be bound to the toggle button and determines whether it is selected or not.
      Returns:
      A builder instance for the provided JToggleButton, which enables fluent method chaining.
    • of

      public static <B extends JToggleButton> UIForToggleButton<B> of(B component)
      Use this to create a builder for the provided JToggleButton instance.
      Type Parameters:
      B - The type of the JToggleButton instance which should be wrapped by the builder.
      Parameters:
      component - The JToggleButton instance which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JToggleButton, which enables fluent method chaining.
    • of

      public static <F extends JTextField> UIForTextField<F> of(F component)
      Use this to create a builder for the provided JTextField instance.
      Type Parameters:
      F - The type of the JTextField instance which should be wrapped by the builder.
      Parameters:
      component - The JTextField instance which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - If the provided text field is null.
    • textField

      public static UIForTextField<JTextField> textField(String text)
      Use this to create a builder for a new JTextField instance with the provided text displayed on it.
      Parameters:
      text - The text which should be displayed on the text field.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
    • textField

      public static UIForTextField<JTextField> textField(sprouts.Val<String> text)
      Use this to create a builder for a new JTextField instance with the provided text property dynamically displaying its value on the text field. The property is a Val, meaning that it is read-only and may not be changed by the text field.
      Parameters:
      text - The text property which should be bound to the text field.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
    • textField

      public static UIForTextField<JTextField> textField(sprouts.Var<String> text)
      Use this to create a builder for a new JTextField instance with the provided text property dynamically displaying its value on the text field. The property may also be modified by the user.
      Parameters:
      text - The text property which should be bound to the text field.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
    • textField

      public static UIForTextField<JTextField> textField()
      Use this to create a builder for a new JTextField UI component. This is in essence a convenience method for UI.of(new JTextField()).
      Returns:
      A builder instance for a new JTextField, which enables fluent method chaining.
    • textField

      public static UIForTextField<JTextField> textField(UI.HorizontalAlignment direction)
      A convenience method for creating a builder for a JTextField with the specified UI.HorizontalAlignment constant as the text orientation. You may also use UIForTextField.withTextOrientation(UI.HorizontalAlignment) to define the text orientation:
      
          UI.textField("may text")
          .withTextOrientation(
              UI.HorizontalAlignment.RIGHT
          );
        
      Parameters:
      direction - The text orientation type which should be used.
      Returns:
      A builder instance for a new JTextField, which enables fluent method chaining.
    • textField

      public static UIForTextField<JTextField> textField(UI.HorizontalAlignment orientation, String text)
      A convenience method for creating a builder for a JTextField with the specified text and text orientation. You may also use UIForAnyTextComponent.withText(String) and UIForTextField.withTextOrientation(UI.HorizontalAlignment) to define the text and text orientation:
      
          UI.textField()
          .withTextOrientation(
              UI.HorizontalAlignment.LEFT
          )
          .withText(text);
        
      Parameters:
      orientation - Defines the orientation of the text inside the text field.
      This may be one of the following constants:
      text - The new text to be set for the wrapped text component type.
      Returns:
      A builder instance for a new JTextField, which enables fluent method chaining.
    • textField

      public static UIForTextField<JTextField> textField(UI.HorizontalAlignment textOrientation, sprouts.Var<String> text)
      Creates a UI builder for a text field where the text is aligned according to the provided UI.HorizontalAlignment constant, and the text of the text field is bound to a string property. Whenever the user modifies the text inside the text field, the value of the property will be updated accordingly. Conversely, when the state of the property is modified inside your view model through the Var.set(Object) method, the text field will be updated accordingly.

      You may also use UIForTextField.withTextOrientation(UI.HorizontalAlignment) and UIForAnyTextComponent.withText(Var) to define the text orientation and text property of the text field:

      
        UI.textField()
        .withTextOrientation(
          UI.HorizontalAlignment.RIGHT
        )
        .withText(textProperty);
        
      Parameters:
      textOrientation - The orientation of the text inside the text field.
      text - A string property which is used to model the text of this text field.
      Returns:
      A text field UI builder for declarative UI design based on method chaining and nesting of SwingTree builder types.
    • textField

      public static UIForTextField<JTextField> textField(UI.HorizontalAlignment orientation, sprouts.Val<String> text)
      Creates a UI builder for a text field where the text is aligned according to the provided UI.HorizontalAlignment constant, and the text of the text field is uni-directionally bound to a string property. Whenever the state of the property is modified inside your view model through the Var.set(Object) method, the text field will be updated accordingly.
      But note that when the user modifies the text inside the text field, the value of the property will not be updated.

      You may also use UIForTextField.withTextOrientation(UI.HorizontalAlignment) and UIForAnyTextComponent.withText(Val) to define the text orientation and text property of the text field:

      
        UI.textField()
        .withTextOrientation(
          UI.HorizontalAlignment.RIGHT
        )
        .withText(readOnlyTextProperty);
        
      Parameters:
      orientation - The orientation of the text inside the text field. This is the direction in which the text is aligned.
      It may be one of the following constants:
      text - A string property which is used to model the text of this text field uni-directionally (read-only).
      Returns:
      A text field UI builder for declarative UI design based on method chaining and nesting of SwingTree builder types.
    • numericTextField

      public static <N extends Number> UIForTextField<JTextField> numericTextField(sprouts.Var<N> number)
      Use this to create a builder for a new JTextField instance with the provided number property dynamically displaying its value on the text field. The property is a Var, meaning that it can be modified by the user.

      The number property will only receive values if the text field contains a valid number.

      Also note that the provided property is not allowed to contain null values, as this would lead to a NullPointerException being thrown.

      Type Parameters:
      N - The type of the number property which should be bound to the text field.
      Parameters:
      number - The number property which should be bound to the text field.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
    • numericTextField

      public static <N extends Number> UIForTextField<JTextField> numericTextField(sprouts.Var<N> number, Function<N,String> formatter)
      Use this to create a builder for a new JTextField instance with the provided number property dynamically displaying its value on the text field and a function which will be used to format the number as a string.

      The number property will only receive values if the text in the text field can be parsed as a number, in which case the provided formatter function will be used to convert the number to a string.

      Note that the provided property is not allowed to contain null values, as this would lead to a NullPointerException being thrown.

      Type Parameters:
      N - The type of the number property which should be bound to the text field.
      Parameters:
      number - The number property which should be bound to the text field.
      formatter - The function which will be used to format the number as a string.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
    • numericTextField

      public static <N extends Number> UIForTextField<JTextField> numericTextField(sprouts.Var<N> number, sprouts.Var<Boolean> isValid)
      Use this to create a builder for a new JTextField instance with the provided number property dynamically displaying its value on the text field and a boolean property which will be set to true if the text field contains a valid number, and false otherwise.

      The number property will only receive values if the text in the text field can be parsed as a number, in which case the provided Var will be set to true, otherwise it will be set to false.

      Note that the two provided properties are not permitted to contain null values, as this would lead to a NullPointerException being thrown.

      Type Parameters:
      N - The type of the number property which should be bound to the text field.
      Parameters:
      number - The number property which should be bound to the text field.
      isValid - A Var which will be set to true if the text field contains a valid number, and false otherwise.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if number is null.
      IllegalArgumentException - if isValid is null.
    • numericTextField

      public static <N extends Number> UIForTextField<JTextField> numericTextField(sprouts.Var<N> number, sprouts.Var<Boolean> isValid, Function<N,String> formatter)
      Use this to create a builder for a new JTextField instance with the provided number property dynamically displaying its value on the text field and a boolean property which will be set to true if the text field contains a valid number, and false otherwise.

      The number property will only receive values if the text in the text field can be parsed as a number, in which case the provided Var will be set to true, otherwise it will be set to false.

      Note that the two provided properties are not permitted to contain null values, as this would lead to a NullPointerException being thrown.

      Type Parameters:
      N - The type of the number property which should be bound to the text field.
      Parameters:
      number - The number property which should be bound to the text field.
      isValid - A Var which will be set to true if the text field contains a valid number, and false otherwise.
      formatter - The function which will be used to format the number as a string.
      Returns:
      A builder instance for the provided JTextField, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if number is null.
      IllegalArgumentException - if isValid is null.
    • of

      public static UIForFormattedTextField of(JFormattedTextField component)
      Use this to create a builder for the provided JFormattedTextField instance.
      Parameters:
      component - The JFormattedTextField instance which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JFormattedTextField, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • formattedTextField

      public static UIForFormattedTextField formattedTextField(String text)
      Use this to create a builder for a new JFormattedTextField instance with the provided text displayed on it.
      Parameters:
      text - The text which should be displayed on the text field.
      Returns:
      A builder instance for the provided JFormattedTextField, which enables fluent method chaining.
    • formattedTextField

      public static UIForFormattedTextField formattedTextField(sprouts.Val<String> text)
      Use this to create a builder for a new JFormattedTextField instance with the provided text property dynamically displaying its value in the text field. The property is a Val, meaning that it is read-only and may not be changed by the text field.
      Parameters:
      text - The text property which should be bound to the text field.
      Returns:
      A builder instance for the provided JFormattedTextField, which enables fluent method chaining.
    • formattedTextField

      public static UIForFormattedTextField formattedTextField(sprouts.Var<String> text)
      Use this to create a builder for a new JFormattedTextField instance with the provided text property dynamically displaying its value in the formatted text field. The property may also be modified by the user.
      Parameters:
      text - The text property which should be bound to the formatted text field.
      Returns:
      A builder instance for the provided JFormattedTextField, which enables fluent method chaining.
    • formattedTextField

      public static UIForFormattedTextField formattedTextField()
      Use this to create a builder for a new JFormattedTextField UI component. This is in essence a convenience method for UI.of(new JFormattedTextField()).
      Returns:
      A builder instance for a new JFormattedTextField, which enables fluent method chaining.
    • of

      public static <F extends JPasswordField> UIForPasswordField<F> of(F passwordField)
      Use this to create a builder for the provided JPasswordField instance.
      Type Parameters:
      F - The type of the JPasswordField instance which should be wrapped by the builder.
      Parameters:
      passwordField - The JPasswordField instance which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JPasswordField, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • passwordField

      public static UIForPasswordField<JPasswordField> passwordField(String text)
      Use this to create a builder for a new JPasswordField instance with the provided text as the initial password.
      Parameters:
      text - The initial password which should be displayed on the password field.
      Returns:
      A builder instance for the provided JPasswordField, which enables fluent method chaining.
    • passwordField

      public static UIForPasswordField<JPasswordField> passwordField(sprouts.Val<String> text)
      Use this to create a builder for a new JPasswordField instance with the provided text property dynamically displaying its value in the password field. The property is a Val, meaning that it is read-only and may not be changed by the password field.
      Parameters:
      text - The text property which should be bound to the password field.
      Returns:
      A builder instance for the provided JPasswordField, which enables fluent method chaining.
    • passwordField

      public static UIForPasswordField<JPasswordField> passwordField(sprouts.Var<String> text)
      Use this to create a builder for a new JPasswordField instance with the provided text property dynamically displaying its value in the password field. The property may also be modified by the user.
      Parameters:
      text - The text property which should be bound to the password field.
      Returns:
      A builder instance for the provided JPasswordField, which enables fluent method chaining.
    • passwordField

      public static UIForPasswordField<JPasswordField> passwordField()
      Use this to create a builder for a new JPasswordField UI component. This is in essence a convenience method for UI.of(new JPasswordField()).
      Returns:
      A builder instance for a new JPasswordField, which enables fluent method chaining.
    • of

      public static <P extends JProgressBar> UIForProgressBar<P> of(P progressBar)
      Use this to create a builder for the provided JProgressBar instance.
      Type Parameters:
      P - The type of the JProgressBar instance which should be wrapped by the builder.
      Parameters:
      progressBar - The JProgressBar instance which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
      Throws:
      IllegalArgumentException - if component is null.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar()
      A factory method for creating a progress bar builder with a default JProgressBar implementation.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(int min, int max)
      Use this to create a builder for a new JProgressBar instance with the provided minimum and maximum values.
      Parameters:
      min - The minimum value of the progress bar.
      max - The maximum value of the progress bar.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(int min, int max, int value)
      Use this to create a builder for a new JProgressBar instance with the provided minimum, maximum and current value.
      Parameters:
      min - The minimum value of the progress bar.
      max - The maximum value of the progress bar.
      value - The current value of the progress bar.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(int min, int max, sprouts.Val<Integer> value)
      Use this to create a builder for a new JProgressBar instance with the provided minimum, maximum and current value property dynamically bound to the progress bar.
      Parameters:
      min - The minimum value of the progress bar.
      max - The maximum value of the progress bar.
      value - The current value property of the progress bar.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(UI.Align align, int min, int max)
      Use this to create a builder for a new JProgressBar instance with the provided alignment, minimum and maximum values. The alignment is a UI.Align value, which may be either UI.Align.HORIZONTAL or UI.Align.VERTICAL.
      Parameters:
      align - The alignment of the progress bar.
      min - The minimum value of the progress bar.
      max - The maximum value of the progress bar.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(UI.Align align, int min, int max, int value)
      Use this to create a builder for a new JProgressBar instance with the provided alignment, minimum, maximum and current value. The alignment is a UI.Align value, which may be either UI.Align.HORIZONTAL or UI.Align.VERTICAL.
      Parameters:
      align - The alignment of the progress bar.
      min - The minimum value of the progress bar.
      max - The maximum value of the progress bar.
      value - The current value of the progress bar.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(UI.Align align, int min, int max, sprouts.Val<Integer> value)
      Use this to create a builder for a new JProgressBar instance with the provided alignment, minimum, maximum and current value property dynamically bound to the progress bar. The alignment is a UI.Align value, which may be either UI.Align.HORIZONTAL or UI.Align.VERTICAL.
      Parameters:
      align - The alignment of the progress bar.
      min - The minimum value of the progress bar.
      max - The maximum value of the progress bar.
      value - The current value property of the progress bar.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(UI.Align align, sprouts.Val<Double> progress)
      Use this to create a builder for a new JProgressBar instance with a default minimum and maximum value of 0 and 100 and the provided alignment and double based progress property (a property wrapping a double value between 0 and 1) dynamically bound to the progress bar. The alignment is a UI.Align value, which may be either UI.Align.HORIZONTAL or UI.Align.VERTICAL.
      Parameters:
      align - The alignment of the progress bar.
      progress - The current progress property of the progress bar, a property wrapping a double value between 0 and 1.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(UI.Align align, double progress)
      Use this to create a builder for a new JProgressBar instance with a default minimum and maximum value of 0 and 100 and the provided alignment and double based progress property (a property wrapping a double value between 0 and 1) dynamically bound to the progress bar. The alignment is a UI.Align value, which may be either UI.Align.HORIZONTAL or UI.Align.VERTICAL.
      Parameters:
      align - The alignment of the progress bar.
      progress - The current progress property of the progress bar, a property wrapping a double value between 0 and 1.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • progressBar

      public static UIForProgressBar<JProgressBar> progressBar(sprouts.Val<UI.Align> align, sprouts.Val<Double> progress)
      Use this to create a builder for a new JProgressBar instance with a default minimum and maximum value of 0 and 100 and the provided alignment property and double based progress property (a property wrapping a double value between 0 and 1) dynamically bound to the progress bar. The alignment property wraps a UI.Align value, which may be either UI.Align.HORIZONTAL or UI.Align.VERTICAL. When any of the two properties change in your view model, the progress bar will be updated accordingly.
      Parameters:
      align - The alignment of the progress bar.
      progress - The current progress property of the progress bar, a property wrapping a double value between 0 and 1.
      Returns:
      A builder instance for the provided JProgressBar, which enables fluent method chaining.
    • of

      public static <A extends JTextArea> UIForTextArea<A> of(A area)
      Use this to create a builder for the provided JTextArea instance.
      Type Parameters:
      A - The type of the JTextArea for which the builder should be created.
      Parameters:
      area - The JTextArea which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JTextArea, which enables fluent method chaining.
    • textArea

      public static UIForTextArea<JTextArea> textArea(String text)
      Use this to create a builder for a new JTextArea instance with the provided text as the initial text.
      Parameters:
      text - The initial text which should be displayed on the text area.
      Returns:
      A builder instance for the provided JTextArea, which enables fluent method chaining.
    • textArea

      public static UIForTextArea<JTextArea> textArea(sprouts.Val<String> text)
      Use this to create a builder for a new JTextArea instance with the provided text property dynamically displaying its value in the text area. The property is a Val, meaning that it is read-only and may not be changed by the text area.
      Parameters:
      text - The text property which should be bound to the text area.
      Returns:
      A builder instance for the provided JTextArea, which enables fluent method chaining.
    • textArea

      public static UIForTextArea<JTextArea> textArea(sprouts.Var<String> text)
      Use this to create a builder for a new JTextArea instance with the provided text property dynamically displaying its value in the text area. The property may also be modified by the user.
      Parameters:
      text - The text property which should be bound to the text area.
      Returns:
      A builder instance for the provided JTextArea, which enables fluent method chaining.
    • of

      public static <E> UIForList<E,JList<E>> of(JList<E> list)
      Use this to create a builder for a concrete JList component type instance. This method allows you to easily integrate custom JList implementations into the SwingTree framework.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      list - The JList which should be wrapped by the builder.
      Returns:
      A builder instance for the provided JList.
    • list

      public static <E> UIForList<E,JList<E>> list()
      Allows for the creation of a declarative UI for the JList component type.
      Type Parameters:
      E - The type of the elements in the list.
      Returns:
      A builder instance for a new JList.
    • list

      public static <E> UIForList<E,JList<E>> list(ListModel<E> model)
      Allows for the creation of a declarative UI for a new JList instance with a custom list model.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      model - The model which should be used for the new JList.
      Returns:
      A builder instance for a new JList.
    • list

      @SafeVarargs public static <E> UIForList<E,JList<E>> list(E... elements)
      Creates a new JList instance builder with the provided array as data model. This is functionally equivalent to listOf(Object...).
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      elements - The elements which should be used as model data for the new JList.
      Returns:
      A builder instance for a new JList with the provided array as data model.
    • list

      public static <E> UIForList<E,JList<E>> list(sprouts.Vals<E> elements)
      Allows for the creation of a new JList instance with the provided observable property list (a Vals object) as data model. When the property list changes, the JList will be updated accordingly.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      elements - The elements which should be used as model data for the new JList.
      Returns:
      A builder instance for a new JList with the provided Vals as data model.
    • listOf

      public static <E> UIForList<E,JList<E>> listOf(sprouts.Vals<E> elements)
      A functionally identical alias method for list(Vals), which allows for the creation of a new JList instance with the provided observable property list (a Vals object) as data model. When the property list changes, the JList will be updated accordingly.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      elements - The elements which should be used as model data for the new JList.
      Returns:
      A builder instance for a new JList with the provided Vals as data model.
    • list

      public static <E> UIForList<E,JList<E>> list(sprouts.Var<E> selection, sprouts.Vals<E> elements)
      Allows for the creation of a new JList instance with 2 observable collections as data model, a Var property for the selection and a Vals property list for the elements. When any of the properties change, the JList will be updated accordingly, and conversely, when the JList selection changes, the properties will be updated accordingly.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The Var property which should be bound to the selection of the JList.
      elements - The Vals property which should be bound to the displayed elements of the JList.
      Returns:
      A builder instance for a new JList with the provided arguments as data model.
    • list

      public static <E> UIForList<E,JList<E>> list(sprouts.Val<E> selection, sprouts.Vals<E> elements)
      Allows for the creation of a new JList instance with 2 observable collections as data model, a Val property for the selection and a Vals property list for the elements. When any of the properties change, the JList will be updated accordingly, however, due to the usage of a read only Val property for the selection, the JList selection will not be updated when the property changes. If you want a bidirectional binding, use list(Var, Vals) instead.
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      selection - The Val property which should be bound to the selection of the JList.
      elements - The Vals property which should be bound to the displayed elements of the JList.
      Returns:
      A builder instance for a new JList with the provided Val and Vals as data models.
    • listOf

      @SafeVarargs public static <E> UIForList<E,JList<E>> listOf(E... elements)
      Creates a new JList instance with the provided array as data model. This is functionally equivalent to list(Object...).
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      elements - The elements which should be used as model data for the new JList.
      Returns:
      A builder instance for a new JList with the provided array as data model.
    • list

      public static <E> UIForList<E,JList<E>> list(List<E> entries)
      Creates a new JList instance with the provided UI.List as data model. This is functionally equivalent to listOf(java.util.List).
      Type Parameters:
      E - The type parameter defining the concrete type of the list entries.
      Parameters:
      entries - The list of entries used for populating a new JList component.
      Returns:
      A builder instance for a new JList with the provided UI.List as data model.
    • listOf

      public static <E> UIForList<E,JList<E>> listOf(List<E> entries)
      Creates a new JList instance with the provided UI.List as data model. This is functionally equivalent to list(java.util.List).
      Type Parameters:
      E - The type of the elements in the list.
      Parameters:
      entries - The elements which should be used as model data for the new JList.
      Returns:
      A builder instance for a new JList with the provided UI.List as data model.
    • of

      public static <T extends JTable> UIForTable<T> of(T table)
      Allows you to wrap the provided JTable type in a declarative UI builder. This is useful when you want to use a custom JTable implementation in the SwingTree framework.
      Type Parameters:
      T - The JTable type.
      Parameters:
      table - The table which should be wrapped by the builder.
      Returns:
      A builder instance for a new JTable.
    • table

      public static UIForTable<JTable> table()
      Creates a declarative UI builder for the JTable component type.
      Returns:
      A fluent builder instance for a new JTable.
    • table

      public static <E> UIForTable<JTable> table(UI.ListData dataFormat, TableListDataSource<E> dataSource)
      Use this to create a new JTable with a table model whose data can be represented based on a list of lists of entries.
      This method will automatically create a AbstractTableModel instance for you.

      Please note that when the data of the provided data source changes (i.e. when the data source is a List which gets modified), the table model will not be updated automatically! Use UIForTable.updateTableOn(sprouts.Event) to bind an update Event to the table model.

      Type Parameters:
      E - The type of the table entry Objects.
      Parameters:
      dataFormat - An enum which configures the modifiability of the table in a readable fashion.
      dataSource - The TableMapDataSource returning a column major map based matrix which will be used to populate the table.
      Returns:
      This builder node.
    • table

      public static <E> UIForTable<JTable> table(UI.MapData dataFormat, TableMapDataSource<E> dataSource)
      Use this to create a new JTable with a table model whose data can be represented based on a map of column names to lists of table entries (basically a column major matrix).
      This method will automatically create a AbstractTableModel instance for you.

      Please note that when the data of the provided data source changes (i.e. when the data source is a Map which gets modified), the table model will not be updated automatically! Use UIForTable.updateTableOn(sprouts.Event) to bind an update Event to the table model.

      Type Parameters:
      E - The type of the table entry Objects.
      Parameters:
      dataFormat - An enum which configures the modifiability of the table in a readable fashion.
      dataSource - The TableMapDataSource returning a column major map based matrix which will be used to populate the table.
      Returns:
      This builder node.
    • table

      public static UIForTable<JTable> table(Configurator<BasicTableModel.Builder<Object>> tableModelBuildable)
      Creates a new JTable instance builder with the provided table model configuration as a basis for creating the table model in a declarative fashion.
      It is expected to be used like so:
      
        UI.table( m -> m
          .colCount( () -> data[0].size() )
          .rowCount( () -> data.size() )
          .getsEntryAt((col, row) -> data[col][row] )
       )
       
      The purpose of this pattern is to remove the necessity of implementing the TableModel interface manually, which is a rather tedious task. Instead, you can use ths fluent API provided by the BasicTableModel.Builder to create a general purpose table model for your table.
      Parameters:
      tableModelBuildable - A lambda function which takes in model builder and then returns a fully configured model builder used as a basis for the table model.
      Returns:
      This builder instance, to allow for further method chaining.
    • table

      public static <T> UIForTable<JTable> table(Class<T> itemType, Configurator<BasicTableModel.Builder<T>> tableModelBuildable)
      Creates a new JTable instance builder with the provided table model configuration as a basis for creating the table model in a declarative fashion.
      It is expected to be used like so:
      
        UI.table(Double.class, m -> m
          .colCount( () -> data[0].size() )
          .rowCount( () -> data.size() )
          .getsEntryAt((col, row) -> data[col][row] )
       )
       
      This API removes the necessity to implement the TableModel interface manually, which is a rather tedious task. Instead, you can configure a model step by step through a Configurator function receiving the fluent builder API provided by the BasicTableModel.Builder.
      Parameters:
      tableModelBuildable - A lambda function which takes in model builder and then returns a fully configured model builder used as a basis for the table model.
      Returns:
      This builder instance, to allow for further method chaining.
    • of

      public static <H extends UI.TableHeader> UIForTableHeader<H> of(H header)
      Allows you to wrap a custom JTableHeader type in a declarative SwingTree UI builder.
      Type Parameters:
      H - The type of the JTableHeader for which the builder should be created.
      Parameters:
      header - The table header which should be wrapped by the builder.
      Returns:
      A builder instance for a new JTableHeader.
    • tableHeader

      public static UIForTableHeader<UI.TableHeader> tableHeader()
      Allows you to create a declarative builder for the JTableHeader UI component.
      Returns:
      A builder instance for a new JTableHeader.
    • of

      public static <F extends JFrame> UIForJFrame<F> of(F frame)
      This returns an instance of a SwingTree builder for a JFrame type.
      Type Parameters:
      F - The concrete type of this new frame.
      Parameters:
      frame - The new frame instance which ought to be part of the Swing UI.
      Returns:
      A basic UI builder instance wrapping a JFrame.
    • frame

      public static UIForJFrame<JFrame> frame()
      Use this to create a builder for the supplied JFrame.
      This is in essence a convenience method for UI.of(new JFrame()) ).
      Returns:
      A basic UI builder instance wrapping a JFrame.
    • frame

      public static UIForJFrame<JFrame> frame(String title)
      Use this to create a builder for the supplied JFrame with the supplied title.
      Parameters:
      title - The title for the new frame.
      Returns:
      A basic UI builder instance wrapping a JFrame.
    • of

      public static <D extends JDialog> UIForJDialog<D> of(D dialog)
      This returns an instance of a SwingTree builder for a JDialog type.
      Type Parameters:
      D - The concrete type of this new dialog.
      Parameters:
      dialog - The new dialog instance which ought to be part of the Swing UI.
      Returns:
      A basic UI builder instance wrapping a JDialog.
    • dialog

      public static UIForJDialog<JDialog> dialog()
      Use this to create a builder for the supplied JDialog.
      This is in essence a convenience method for UI.of(new JDialog()) ).
      Returns:
      A basic UI builder instance wrapping a JDialog.
    • dialog

      public static UIForJDialog<JDialog> dialog(Window owner)
      Use this to create a builder for the supplied JDialog with the supplied owner.
      Parameters:
      owner - The owner for the new dialog.
      Returns:
      A basic UI builder instance wrapping a JDialog.
    • dialog

      public static UIForJDialog<JDialog> dialog(String title)
      Use this to create a builder for the supplied JDialog with the supplied title.
      Parameters:
      title - The title for the new dialog.
      Returns:
      A basic UI builder instance wrapping a JDialog.
    • dialog

      public static UIForJDialog<JDialog> dialog(Window owner, String title)
      Use this to create a builder for the supplied JDialog with the supplied owner and title.
      Parameters:
      owner - The owner for the new dialog.
      title - The title for the new dialog.
      Returns:
      A basic UI builder instance wrapping a JDialog.
    • animateFor

      public static Animator animateFor(long duration, TimeUnit unit)
      Exposes an API for scheduling periodic animation updates. This is a convenience method for Animator.animateFor(LifeTime).
      A typical usage would be:
      
          UI.animateFor( 100, TimeUnit.MILLISECONDS )
             .until( it -> it.progress() >= 0.75 && someOtherCondition() )
             .go( it -> {
                // do something
                someComponent.setValue( it.progress() );
                // ...
                someComponent.repaint();
             });
        
      Parameters:
      duration - The duration of the animation. This is the time it takes for the animation to reach 100% progress.
      unit - The time unit of the duration.
      Returns:
      An Animator instance which allows you to configure the animation.
    • animateFor

      public static Animator animateFor(double duration, TimeUnit unit)
      Exposes a builder API for creating and scheduling periodic animation updates. This is a convenience method for Animator.animateFor(LifeTime).
      A typical usage would be:
      
          UI.animateFor( 0.1, TimeUnit.MINUTES )
             .until( it -> it.progress() >= 0.75 && someOtherCondition() )
             .go( it -> {
                // do something
                someComponent.setBackground( new Color( 0, 0, 0, (int)(it.progress()*255) ) );
                // ...
                someComponent.repaint();
             });
        
      Parameters:
      duration - The duration of the animation. This is the time it takes for the animation to reach 100% progress.
      unit - The time unit of the duration.
      Returns:
      An Animator instance which allows you to configure the animation.
    • animateFor

      public static Animator animateFor(double duration, TimeUnit unit, Stride stride)
      Exposes a builder API for creating and scheduling periodic animation updates. This is a convenience method for Animator.animateFor(LifeTime, Stride).
      A typical usage would be:
      
          UI.animateFor( 0.1, TimeUnit.MINUTES, Stride.REGRESSIVE )
             .until( it -> it.progress() < 0.75 && someOtherCondition() )
             .go( it -> {
                // do something
                someComponent.setBackground( new Color( 0, 0, 0, (int)(it.progress()*255) ) );
                // ...
                someComponent.repaint();
             });
        
      Parameters:
      duration - The duration of the animation. This is the time it takes for the animation to reach 100% progress.
      unit - The time unit of the duration.
      stride - The stride of the animation, which determines whether the animation progresses going forward or backwards.
      Returns:
      An Animator instance which allows you to configure the animation.
    • animateFor

      public static Animator animateFor(LifeTime duration)
      Exposes an API for scheduling periodic animation updates. This is a convenience method for Animator.animateFor(LifeTime).
      A typical usage would be:
      
          UI.animateFor( LifeTime.of(0.1, TimeUnit.MINUTES) )
             .until( it -> it.progress() >= 0.75 && someOtherCondition() )
             .go( it -> {
                // do something
                someComponent.setBackground( new Color( 0, 0, 0, (int)(it.progress()*255) ) );
                // ...
                someComponent.repaint();
             });
        
      Parameters:
      duration - The duration of the animation. This is the time it takes for the animation to reach 100% progress.
      Returns:
      An Animator instance which allows you to configure the animation.
    • animateFor

      public static Animator animateFor(LifeTime duration, Component component)
      Exposes an API for scheduling periodic animation updates for a specific component whose Component.repaint() method should be called after every animation update. This is a convenience method for Animator.animateFor(LifeTime).
      A typical usage would be:
      
          UI.animateFor( UI.lifeTime(0.1, TimeUnit.MINUTES), someComponent )
             .until( it -> it.progress() >= 0.75 && someOtherCondition() )
             .go( it -> {
                // do something
                someComponent.setBackground( new Color( 0, 0, 0, (int)(it.progress()*255) ) );
             });
        
      Parameters:
      duration - The duration of the animation. This is the time it takes for the animation to reach 100% progress.
      component - The component which should be repainted after every animation update.
      Returns:
      An Animator instance which allows you to configure the animation.
    • lifeTime

      public static LifeTime lifeTime(long duration, TimeUnit unit)
      A factory method for creating a LifeTime instance with the given duration and time unit. This is a convenience method for LifeTime.of(long, TimeUnit). The LifeTime instance is an immutable value type which is used for scheduling animations, usually through Animator.animateFor(LifeTime) or the convenience methods animateFor(long, TimeUnit), animateFor(double, TimeUnit), animateFor(LifeTime) or animateFor(LifeTime, java.awt.Component). A typical usage would be:
      
            UI.animateFor( UI.lifeTime(0.1, TimeUnit.MINUTES) )
            .until( it -> it.progress() >= 0.75 && someOtherCondition() )
            .go( it -> {
                // do something
            });
        
      Parameters:
      duration - The duration of the animation.
      unit - The time unit of the duration.
      Returns:
      A LifeTime instance.
    • info

      public static void info(String message)
      Shows an info dialog with the given message.
      Parameters:
      message - The message to show in the dialog.
    • info

      public static void info(String title, String message)
      Shows an info dialog with the given message and dialog title.
      Parameters:
      title - The title of the dialog.
      message - The message to show in the dialog.
    • warn

      public static void warn(String message)
      Shows a warning dialog with the given message.
      Parameters:
      message - The warning message to show in the dialog.
    • warn

      public static void warn(String title, String message)
      Shows a warning dialog with the given message and dialog title.
      Parameters:
      title - The title of the dialog.
      message - The warning message to show in the dialog.
    • error

      public static void error(String message)
      Shows an error dialog with the given message.
      Parameters:
      message - The error message to show in the dialog.
    • error

      public static void error(String title, String message)
      Shows an error dialog with the given message and dialog title.
      Parameters:
      title - The title of the dialog.
      message - The error message to show in the dialog.
    • message

      public static MessageDialog message(String text)
      Exposes the MessageDialog API, an immutable builder config for creating a message dialog with a given message text. Call methods like MessageDialog.showAsInfo(), MessageDialog.showAsWarning() or MessageDialog.showAsError() to show the dialog in the desired style.
      Parameters:
      text - The text to show in the dialog.
      Returns:
      A builder for creating an error dialog.
    • confirm

      public static ConfirmAnswer confirm(String message)
      Shows a conformation dialog with the given message and returns the user's answer in the form of a ConfirmAnswer enum constant.
      Parameters:
      message - the message to show
      Returns:
      Answer.YES if the user clicked "Yes", Answer.NO if the user clicked "No", Answer.CANCEL otherwise.
    • confirm

      public static ConfirmAnswer confirm(String title, String message)
      Shows a conformation dialog with the given title and message and returns the user's answer in the form of a ConfirmAnswer enum constant.
      Parameters:
      title - the title of the dialog
      message - the message to show
      Returns:
      Answer.YES if the user clicked "Yes", Answer.NO if the user clicked "No", Answer.CANCEL otherwise.
    • confirmation

      public static ConfirmDialog confirmation(String toBeConfirmed)
      Exposes the ConfirmDialog API, an immutable builder config type for creating a confirmation dialog designed to ask a question. The supplied string will be used as the question to ask the user when the dialog is shown using the ConfirmDialog.showAsQuestion() method.
      Parameters:
      toBeConfirmed - The question to ask the user.
      Returns:
      A builder for creating a confirmation dialog designed to ask a question.
    • ask

      public static <E extends Enum<E>> Optional<E> ask(String question, sprouts.Var<E> selected)
      Shows a dialog where the user can select a value from a list of options based on the enum type implicitly defined by the given enum based property. The selected value will be stored in said property after the user has selected a value and also returned as an Optional. If no value is selected, the returned Optional will be empty and the property will not be changed.
      Type Parameters:
      E - The enum type.
      Parameters:
      question - The message to show in the dialog.
      selected - The enum based property to store the selected value in.
      Returns:
      The selected enum value wrapped in an Optional or an empty optional if the user cancelled the dialog.
    • ask

      public static <E extends Enum<E>> Optional<E> ask(String title, String message, sprouts.Var<E> selected)
      Shows a dialog where the user can select a value from a list of options based on the enum type implicitly defined by the given enum based property. The selected value will be stored in said property after the user has selected a value.
      Type Parameters:
      E - The enum type.
      Parameters:
      title - The title of the dialog.
      message - The message to show in the dialog.
      selected - The enum based property to store the selected value in.
      Returns:
      The selected enum value wrapped in an Optional or an empty optional if the user cancelled the dialog.
    • ask

      public static <E extends Enum<E>> void ask(String title, String message, Icon icon, sprouts.Var<E> selected)
      Shows a dialog where the user can select a value from a list of options based on the enum type implicitly defined by the given enum based property. The selected value will be stored in said property after the user has selected a value.
      Type Parameters:
      E - The type parameter defining the concrete enum type.
      Parameters:
      title - The title of the dialog.
      message - The message to show in the dialog.
      icon - The icon to show in the dialog.
      selected - The enum based property to store the selected value in.
    • choice

      @SafeVarargs public static <E extends Enum<E>> OptionsDialog<E> choice(String offer, E... options)
      Exposes the OptionsDialog API for creating a question dialog that allows the user to select a value from an array of provided enum values.
      Type Parameters:
      E - The enum type.
      Parameters:
      offer - The message to show in the dialog.
      options - The array of enum values to show in the dialog.
      Returns:
      A builder for creating a question dialog with a set of selectable enum values based on the provided array of enum values.
    • choice

      public static <E extends Enum<E>> OptionsDialog<E> choice(String offer, sprouts.Var<E> selectable)
      Exposes the OptionsDialog API for creating a question dialog that allows the user to select and set a value from the provided enum based property.
      Type Parameters:
      E - The enum type.
      Parameters:
      offer - The message to show in the dialog.
      selectable - The enum based property to store the selected value in.
      Returns:
      A builder for creating a question dialog with a set of selectable enum values based on the provided array of enum values.
    • show

      public static void show(Component component)
      Use this to quickly launch a UI component in a JFrame window at the center of the screen.
      Warning: This method should only be invoked from the Event Dispatch Thread (EDT). You may encounter unexpected behavior if you call this method from another thread.
      Use show(Function) instead to ensure that the UI is created on the EDT.
      Parameters:
      component - The component to show in the window.
    • show

      public static void show(String title, Component component)
      Use this to quickly launch a UI component in a titled JFrame window at the center of the screen.
      Warning: This method should only be invoked from the Event Dispatch Thread (EDT). You may encounter unexpected behavior if you call this method from another thread.
      Use show(String, Function) instead to ensure that the UI is created on the EDT.
      Parameters:
      title - The title of the window.
      component - The component to show in the window.
    • show

      public static <C extends JComponent> void show(UIForAnySwing<?,C> ui)
      Use this to quickly launch a UI component in a JFrame window at the center of the screen.
      Warning: This method should only be invoked from the Event Dispatch Thread (EDT). You may encounter unexpected behavior if you call this method from another thread.
      Use show(Function) instead to ensure that the UI is created on the EDT.
      Type Parameters:
      C - The type of the component to show in the window.
      Parameters:
      ui - The SwingTree UI to show in the window.
    • show

      public static <C extends JComponent> void show(String title, UIForAnySwing<?,C> ui)
      Use this to quickly launch a UI component in a titled JFrame window at the center of the screen.
      Warning: This method should only be invoked from the Event Dispatch Thread (EDT). You may encounter unexpected behavior if you call this method from another thread.
      Use show(String, Function) instead to ensure that the UI is created on the EDT.
      Type Parameters:
      C - The type of the component to show in the window.
      Parameters:
      title - The title of the window.
      ui - The SwingTree UI to show in the window.
    • show

      public static void show(Function<JFrame,Component> uiSupplier)
      Use this to quickly launch a UI component in a JFrame window at the center of the screen using a function receiving the JFrame and returning the component to be shown.
      Parameters:
      uiSupplier - The component supplier which receives the current JFrame and returns the component to be shown.
    • show

      public static void show(String title, Function<JFrame,Component> uiSupplier)
      Use this to quickly launch a UI component in a titled JFrame window at the center of the screen using a function receiving the JFrame and returning the component to be shown.
      Parameters:
      title - The title of the window.
      uiSupplier - The component supplier which receives the current JFrame and returns the component to be shown.
    • showUsing

      public static void showUsing(EventProcessor eventProcessor, Function<JFrame,Component> uiSupplier)
      Use this to quickly launch a UI component with a custom event processor in JFrame window at the center of the screen.
      Parameters:
      eventProcessor - the event processor to use for the UI built inside the Supplier lambda.
      uiSupplier - The component supplier which builds the UI and supplies the component to be shown.
    • showUsing

      public static void showUsing(EventProcessor eventProcessor, String title, Function<JFrame,Component> uiSupplier)
      Use this to quickly launch a UI component with a custom event processor in a titled JFrame window at the center of the screen.
      Parameters:
      eventProcessor - the event processor to use for the UI built inside the Supplier lambda.
      title - The title of the window.
      uiSupplier - The component supplier which builds the UI and supplies the component to be shown.
    • use

      public static <T> T use(StyleSheet styleSheet, Supplier<T> scope)
      Sets a StyleSheet which will be applied to all SwingTree UIs defined in the subsequent lambda scope. This method allows to switch between different style sheets.

      You can switch to a style sheet like so:

      
       	use(new MyCustomStyeSheet(), ()->
            UI.panel("fill")
            .add( "shrink", UI.label( "Username:" ) )
            .add( "grow, pushx", UI.textField("User1234..42") )
            .add( label( "Password:" ) )
            .add( "grow, pushx", UI.passwordField("child-birthday") )
            .add( "span",
                UI.button("Login!").onClick( it -> {...} )
            )
        );
        
      Type Parameters:
      T - The type of the result of the given scope.
      Parameters:
      styleSheet - The style sheet to be used for all subsequent UI building operations.
      scope - A lambda scope in which the style sheet is active for all subsequent UI building operations.
      Returns:
      the result of the given scope, usually a JComponent or SwingTree UI.
    • use

      public static <T> T use(EventProcessor processor, Supplier<T> scope)
      Sets the EventProcessor to be used for all subsequent UI building operations. This method allows to switch between different event processing strategies. In particular, the EventProcessor.DECOUPLED is recommended to be used for proper decoupling of the UI thread from the application logic.

      You can switch to the decoupled event processor like so:

      
       	use(EventProcessor.DECOUPLED, ()->
            UI.panel("fill")
            .add( "shrink", UI.label( "Username:" ) )
            .add( "grow, pushx", UI.textField("User1234..42") )
            .add( label( "Password:" ) )
            .add( "grow, pushx", UI.passwordField("child-birthday") )
            .add( "span",
                UI.button("Login!").onClick( it -> {...} )
            )
        );
        
      Type Parameters:
      T - The type of the value returned by the given scope.
      Parameters:
      processor - The event processor to be used for all subsequent UI building operations
      scope - The scope of the event processor to be used for all subsequent UI building operations. The value returned by the given scope is returned by this method.
      Returns:
      The value returned by the given scope.
    • findIcon

      public static Optional<ImageIcon> findIcon(String path)
      Loads an ImageIcon from the resource folder, the classpath, a local file or from cache if it has already been loaded. If no icon could be found, an empty optional is returned.

      Note that this method will also return SvgIcon instances, if the icon is an SVG image.

      Also, checkout SwingTree.getIconCache() to see where the icons are cached.
      Parameters:
      path - The path to the icon. It can be a classpath resource or a file path.
      Returns:
      An optional containing the icon if it could be found, an empty optional otherwise.
      Throws:
      NullPointerException - if path is null.
    • findIcon

      public static Optional<ImageIcon> findIcon(IconDeclaration declaration)
      Loads an ImageIcon from the resource folder, the classpath, a local file or from cache if it has already been loaded. If no icon could be found, an empty optional is returned.

      Note that this method will also return SvgIcon instances, if the icon is an SVG image.

      Also, checkout SwingTree.getIconCache() to see where the icons are cached.
      Parameters:
      declaration - The icon declaration, a value object defining the path to the icon.
      Returns:
      An optional containing the icon if it could be found, an empty optional otherwise.
      Throws:
      NullPointerException - if declaration is null.
    • findSvgIcon

      public static Optional<SvgIcon> findSvgIcon(String path)
      Loads an SvgIcon from the resource folder, the classpath, a local file or from cache if it has already been loaded. If no icon could be found, an empty optional is returned.

      Also, checkout SwingTree.getIconCache() to see where the icons are cached.
      Parameters:
      path - The path to the icon. It can be a classpath resource or a file path.
      Returns:
      An optional containing the SvgIcon if it could be found, an empty optional otherwise.
      Throws:
      NullPointerException - if path is null.
    • findSvgIcon

      public static Optional<SvgIcon> findSvgIcon(IconDeclaration declaration)
      Loads an SvgIcon from the resource folder, the classpath, a local file or from cache if it has already been loaded. If no icon could be found, an empty optional is returned.

      Also, checkout SwingTree.getIconCache() to see where the icons are cached.
      Parameters:
      declaration - The icon declaration, a value object defining the path to the icon.
      Returns:
      An optional containing the SvgIcon if it could be found, an empty optional otherwise.
      Throws:
      NullPointerException - if declaration is null.