Class ComponentGroup

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class ComponentGroup extends Container

A component group is a container that applies the given UIID to a set of components within it and gives the same UIID with "First"/"Last" prepended to the first and last components. E.g. by default the GroupElement UIID is applied so the first and last elements would have the GroupElementFirst/GroupElementLast UIID's applied to them. If a group has only one element the word "Only" is appended to the element UIID as in GroupElementOnly.

Important!!! A component group does nothing by default unless explicitly activated by the theme by enabling the ComponentGroupBool constant (by default, this can be customized via the groupFlag property). This allows logical grouping without changing the UI for themes that don't need grouping.

This container uses box X/Y layout (defaults to Y), other layout managers shouldn't be used since this container relies on the specific behavior of the box layout.

Check out this sample code:

hi.add("Three Labels").
        add(ComponentGroup.enclose(new Label("GroupElementFirst UIID"), new Label("GroupElement UIID"), new Label("GroupElementLast UIID"))).
        add("One Label").
        add(ComponentGroup.enclose(new Label("GroupElementOnly UIID"))).
        add("Three Buttons").
        add(ComponentGroup.enclose(new Button("ButtonGroupFirst UIID"), new Button("ButtonGroup UIID"), new Button("ButtonGroupLast UIID"))).
        add("One Button").
        add(ComponentGroup.enclose(new Button("ButtonGroupOnly UIID")));
  • Constructor Details

    • ComponentGroup

      public ComponentGroup()
      Default constructor
  • Method Details

    • enclose

      public static ComponentGroup enclose(Component... cmp)

      Shorthand method for wrapping the given components in a vertical component group

      Parameters
      • cmp: the components to add into a newly created group
      Returns

      the newly created group

    • encloseHorizontal

      public static ComponentGroup encloseHorizontal(Component... cmp)

      Shorthand method for wrapping the given components in a horizontal component group

      Parameters
      • cmp: the components to add into a newly created group
      Returns

      the newly created group

    • refreshTheme

      public void refreshTheme(boolean merge)

      Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!

      Parameters
      • merge: indicates if the current styles should be merged with the new styles
      Overrides:
      refreshTheme in class Container
    • isHorizontal

      public boolean isHorizontal()

      Indicates that the component group should be horizontal by using the BoxLayout Y

      Returns

      the horizontal

    • setHorizontal

      public void setHorizontal(boolean horizontal)

      Indicates that the component group should be horizontal by using the BoxLayout Y

      Parameters
      • horizontal: the horizontal to set
    • getElementUIID

      public String getElementUIID()

      The UIID to apply to the elements within this container

      Returns

      the elementUIID

    • setElementUIID

      public void setElementUIID(String elementUIID)

      The UIID to apply to the elements within this container

      Parameters
      • elementUIID: the elementUIID to set
    • getPropertyNames

      public String[] getPropertyNames()

      A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

      Returns

      the property names allowing mutation

      Overrides:
      getPropertyNames in class Component
    • getPropertyTypes

      public Class[] getPropertyTypes()

      Matches the property names method (see that method for further details).

      Returns

      the types of the properties

      Overrides:
      getPropertyTypes in class Component
    • getPropertyValue

      public Object getPropertyValue(String name)

      Returns the current value of the property name, this method is used by the GUI builder

      Parameters
      • name: the name of the property
      Returns

      the value of said property

      Overrides:
      getPropertyValue in class Component
    • setPropertyValue

      public String setPropertyValue(String name, Object value)

      Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

      Parameters
      • name: the name of the property

      • value: new value for the property

      Returns

      error message or null

      Overrides:
      setPropertyValue in class Component
    • getGroupFlag

      public String getGroupFlag()

      The group flag allows changing the flag that activates this group, from ComponentGroupBool to any arbitrary flag. This allows a developer/designer to enable grouping for a specific type of components (e.g. for horizontal Toggle Buttons) yet disable it for vertical lists of components.

      Returns

      the groupFlag

    • setGroupFlag

      public void setGroupFlag(String groupFlag)

      The group flag allows changing the flag that activates this group, from ComponentGroupBool to any arbitrary flag. This allows a developer/designer to enable grouping for a specific type of components (e.g. for horizontal Toggle Buttons) yet disable it for vertical lists of components.

      Parameters
      • groupFlag: the groupFlag to set
    • isForceGroup

      public boolean isForceGroup()

      Component grouping can be an element from the theme but can be forced manually for a specific group

      Returns

      the forceGroup

    • setForceGroup

      public void setForceGroup(boolean forceGroup)

      Component grouping can be an element from the theme but can be forced manually for a specific group

      Parameters
      • forceGroup: the forceGroup to set