Interface Container

All Superinterfaces:
Component, CompositeComponent, DepictedObject, Displayable, InfoModel, Iterable<Component>, LabelModel, LayoutComponent, Model, PresentationModel, com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable
All Known Subinterfaces:
ArrangeContainer, CardContainer, CardControl, ContainerControl, Menu, ModalNavigationPanel<R>, Panel
All Known Implementing Classes:
AboutPanel, AbstractBox, AbstractCardPanel, AbstractContainer, AbstractContainerControl, AbstractContainerValueControl, AbstractEditComponentTextControl, AbstractEditValuePanel, AbstractListSelectContainerControl, AbstractMenu, AbstractModalNavigationPanel, AbstractPanel, AbstractSequenceTaskPanel, AbstractValuedPanel, AccordionMenu, ArrangePanel, AutoNavigationPathBreadcrumbLinkPanel, BusyPanel, CardPanel, DefaultModalNavigationPanel, DropMenu, EditComponentLabelControl, EditComponentTextControl, GroupPanel, LayoutPanel, NamePanel, NavigationPathBreadcrumbLinkPanel, PasswordAuthenticationPanel, PlatformFileUploadPanel, SectionPanel, SequenceCardPanel, SpinnerControl, TabbedPanel, TabContainerControl, TextBox, Toolbar

public interface Container extends LayoutComponent, Iterable<Component>
Component that allows for addition and removal of child components. A layout component is iterable over its child components, and can be used in short for(:) form.
Author:
Garret Wilson
  • Method Details

    • size

      int size()
      Returns:
      The number of child components in this composite component.
    • isEmpty

      boolean isEmpty()
      Returns:
      Whether this container contains no child components.
    • contains

      boolean contains(Object component)
      Determines whether this container contains the given component.
      Parameters:
      component - The component to check.
      Returns:
      true if this container contains the given component.
    • indexOf

      int indexOf(Object component)
      Returns the index in the container of the first occurrence of the specified component.
      Parameters:
      component - The component the index of which should be returned.
      Returns:
      The index in this container of the first occurrence of the specified component, or -1 if this container does not contain the given component.
    • lastIndexOf

      int lastIndexOf(Object component)
      Returns the index in this container of the last occurrence of the specified compoent.
      Parameters:
      component - The component the last index of which should be returned.
      Returns:
      The index in this container of the last occurrence of the specified component, or -1 if this container does not contain the given component.
    • get

      Component get(int index)
      Returns the component at the specified index in the container.
      Parameters:
      index - The index of component to return.
      Returns:
      The component at the specified position in this container.
      Throws:
      IndexOutOfBoundsException - if the index is out of range.
    • add

      boolean add(Component component)
      Adds a component with default constraints to the container.
      Parameters:
      component - The component to add to this container.
      Returns:
      true if this container changed as a result of the operation.
      Throws:
      IllegalArgumentException - if the component already has a parent.
      IllegalStateException - if the installed layout does not support default constraints.
    • add

      void add(int index, Component component, Constraints constraints)
      Adds a component along with constraints to the container at the specified index. This is a convenience method that first sets the constraints of the component.
      Parameters:
      index - The index at which the component should be added.
      component - The component to add to this container.
      constraints - The constraints for the layout, or null if default constraints should be used.
      Throws:
      IllegalArgumentException - if the component already has a parent.
      ClassCastException - if the provided constraints are not appropriate for the installed layout.
      IllegalStateException - if no constraints were provided and the installed layout does not support default constraints.
      IndexOutOfBoundsException - if the index is less than zero or greater than the number of child components.
    • add

      boolean add(Component component, Constraints constraints)
      Adds a component along with constraints to the container. This is a convenience method that first sets the constraints of the component.
      Parameters:
      component - The component to add to this container.
      constraints - The constraints for the layout, or null if default constraints should be used.
      Returns:
      true if this container changed as a result of the operation.
      Throws:
      IllegalArgumentException - if the component already has a parent.
      ClassCastException - if the provided constraints are not appropriate for the installed layout.
      IllegalStateException - if no constraints were provided and the installed layout does not support default constraints.
    • add

      Component add(int index, Prototype prototype)
      Adds a component based upon the given prototype to the container with default constraints at the specified index.
      Parameters:
      index - The index at which the component should be added.
      prototype - The prototype of the component to add.
      Returns:
      The component created to represent the given prototype.
      Throws:
      IllegalArgumentException - if no component can be created from the given prototype
      IllegalStateException - if the installed layout does not support default constraints.
      IndexOutOfBoundsException - if the index is less than zero or greater than the number of child components.
      See Also:
    • add

      Component add(Prototype prototype)
      Adds a component based upon the given prototype to the container with default constraints.
      Parameters:
      prototype - The prototype of the component to add.
      Returns:
      The component created to represent the given prototype.
      Throws:
      IllegalArgumentException - if no component can be created from the given prototype
      IllegalStateException - if the installed layout does not support default constraints.
      See Also:
    • add

      Component add(int index, Prototype prototype, Constraints constraints)
      Adds a component based upon the given prototype to the container along with constraints at the specified index.
      Parameters:
      index - The index at which the component should be added.
      prototype - The prototype of the component to add.
      constraints - The constraints for the layout, or null if default constraints should be used.
      Returns:
      The component created to represent the given prototype.
      Throws:
      IllegalArgumentException - if no component can be created from the given prototype
      ClassCastException - if the provided constraints are not appropriate for the installed layout.
      IllegalStateException - if no constraints were provided and the installed layout does not support default constraints.
      IndexOutOfBoundsException - if the index is less than zero or greater than the number of child components.
      See Also:
    • add

      Component add(Prototype prototype, Constraints constraints)
      Adds a component based upon the given prototype to the container along with constraints.
      Parameters:
      prototype - The prototype of the component to add.
      constraints - The constraints for the layout, or null if default constraints should be used.
      Returns:
      The component created to represent the given prototype.
      Throws:
      IllegalArgumentException - if no component can be created from the given prototype
      ClassCastException - if the provided constraints are not appropriate for the installed layout.
      IllegalStateException - if no constraints were provided and the installed layout does not support default constraints.
    • remove

      boolean remove(Object component)
      Removes a component from the container.
      Parameters:
      component - The component to remove.
      Returns:
      true if this collection changed as a result of the operation.
      Throws:
      ClassCastException - if given element is not a component.
      IllegalArgumentException - if the component is not a member of the container.
    • remove

      Component remove(int index)
      Removes the child component at the specified position in this container.
      Parameters:
      index - The index of the component to removed.
      Returns:
      The value previously at the specified position.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
    • clear

      void clear()
      Removes all of the components from this container.
    • setLayout

      <T extends Constraints> void setLayout(Layout<T> newLayout)
      Sets the layout definition for the container. The layout definition can only be changed if the container currently has no child components. This is a bound property.
      Type Parameters:
      T - The type of the constraints.
      Parameters:
      newLayout - The new layout definition for the container.
      Throws:
      NullPointerException - if the given layout is null.
      IllegalStateException - if a new layout is requested while this container has one or more children.
      See Also: