# Class ComponentGroup

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Container
com.codename1.ui.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")));

- ## Field Summary

  ### Fields inherited from class Component

  `BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ComponentGroup()`
  Default constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ComponentGroup`
  `enclose(Component... cmp)`
  Shorthand method for wrapping the given components in a vertical component group
  `static ComponentGroup`
  `encloseHorizontal(Component... cmp)`
  Shorthand method for wrapping the given components in a horizontal component group
  `String`
  `getElementUIID()`
  The UIID to apply to the elements within this container
  `String`
  `getGroupFlag()`
  The group flag allows changing the flag that activates this group, from ComponentGroupBool to any arbitrary flag.
  `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
  `Class[]`
  `getPropertyTypes()`
  Matches the property names method (see that method for further details).
  `Object`
  `getPropertyValue(String name)`
  Returns the current value of the property name, this method is used by the GUI builder
  `boolean`
  `isForceGroup()`
  Component grouping can be an element from the theme but can be forced manually for a specific group
  `boolean`
  `isHorizontal()`
  Indicates that the component group should be horizontal by using the BoxLayout Y
  `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!
  `void`
  `setElementUIID(String elementUIID)`
  The UIID to apply to the elements within this container
  `void`
  `setForceGroup(boolean forceGroup)`
  Component grouping can be an element from the theme but can be forced manually for a specific group
  `void`
  `setGroupFlag(String groupFlag)`
  The group flag allows changing the flag that activates this group, from ComponentGroupBool to any arbitrary flag.
  `void`
  `setHorizontal(boolean horizontal)`
  Indicates that the component group should be horizontal by using the BoxLayout Y
  `String`
  `setPropertyValue(String name, Object value)`
  Sets a new value to the given property, returns an error message if failed and null if successful.

  ### Methods inherited from class Container

  `add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerPressed, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndices`

  ### Methods inherited from class Component

  `addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Iterable

  `forEach, spliterator`

- ## 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