Class Form

  • All Implemented Interfaces:
    java.lang.Iterable<Component>, Sequence<Component>, ConstrainedVisual, Visual

    @DefaultProperty("sections")
    public class Form
    extends Container
    A container that arranges field components in a form layout. Each field has an optional text label associated with it and may be flagged as requiring attention using one of several flag types and an optional flag message (for use during form validation, for example).
    • Constructor Detail

      • Form

        public Form()
        Creates a new form.
    • Method Detail

      • getSections

        public Form.SectionSequence getSections()
        Returns the form's field sequence.
        Returns:
        The form's field sequence.
      • clearFlags

        public void clearFlags()
        Clears all field flags.
      • getFlaggedFieldCount

        public int getFlaggedFieldCount​(MessageType messageType)
        Returns the number of fields that are flagged with a given message type.
        Parameters:
        messageType - The message type to count, or null to return the count of all flagged fields regardless of message type.
        Returns:
        The number of flagged fields.
      • scrollFirstFlagToVisible

        public void scrollFirstFlagToVisible​(MessageType messageType)
        Ensures that the first field with the given flag type is visible.
        Parameters:
        messageType - The message type, or null to scroll the first flag of any type to visible.
      • remove

        public Sequence<Component> remove​(int index,
                                          int count)
        Description copied from interface: Sequence
        Removes one or more items from the sequence.
        Specified by:
        remove in interface Sequence<Component>
        Overrides:
        remove in class Container
        Parameters:
        index - The starting index to remove.
        count - The number of items to remove, beginning with index.
        Returns:
        A sequence containing the items that were removed.
      • getSection

        public static Form.Section getSection​(Component component)
        Finds the Form.Section that the given component belongs to. Only finds the section if the component is a direct child of the section.
        Parameters:
        component - The component in question.
        Returns:
        The section this component belongs to.
        See Also:
        getEnclosingSection(Component)
      • getEnclosingSection

        public static Form.Section getEnclosingSection​(Component component)
        Finds the Form.Section that the given component belongs to. Will search up the parent hierarchy in case the component is nested inside other containers inside the form.
        Parameters:
        component - The component in question.
        Returns:
        The form section this component (or one of its parents) belongs to or null if the component does not belong to a form.
        See Also:
        getSection(Component)
      • getLabel

        public static java.lang.String getLabel​(Component component)
      • setLabel

        public static void setLabel​(Component component,
                                    java.lang.String label)
      • isRequired

        public static boolean isRequired​(Component component)
      • setRequired

        public static void setRequired​(Component component,
                                       boolean required)
      • setFlag

        public static final void setFlag​(Component component,
                                         java.lang.String flag)
      • clearFlag

        public static final void clearFlag​(Component component)