Package org.apache.pivot.wtk
Class Form
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- org.apache.pivot.wtk.Container
-
- org.apache.pivot.wtk.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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Form.Flag
Represents an message alert associated with a form field.static class
Form.Section
Class representing a form section.class
Form.SectionSequence
Section sequence implementation.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Container
Container.EDTChecker
-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
-
-
Constructor Summary
Constructors Constructor Description Form()
Creates a new form.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearFlag(Component component)
void
clearFlags()
Clears all field flags.static Form.Section
getEnclosingSection(Component component)
Finds theForm.Section
that the given component belongs to.static Form.Flag
getFlag(Component component)
int
getFlaggedFieldCount(MessageType messageType)
Returns the number of fields that are flagged with a given message type.ListenerList<FormAttributeListener>
getFormAttributeListeners()
ListenerList<FormListener>
getFormListeners()
static java.lang.String
getLabel(Component component)
static Form.Section
getSection(Component component)
Finds theForm.Section
that the given component belongs to.Form.SectionSequence
getSections()
Returns the form's field sequence.static boolean
isRequired(Component component)
Sequence<Component>
remove(int index, int count)
Removes one or more items from the sequence.void
scrollFirstFlagToVisible(MessageType messageType)
Ensures that the first field with the given flag type is visible.static void
setFlag(Component component, java.lang.String flag)
static void
setFlag(Component component, Form.Flag flag)
static void
setLabel(Component component, java.lang.String label)
static void
setRequired(Component component, boolean required)
-
Methods inherited from class org.apache.pivot.wtk.Container
add, assertEventDispatchThread, assertEventDispatchThread, clear, containsFocus, descendantAdded, descendantGainedFocus, descendantLostFocus, descendantRemoved, get, getComponentAt, getContainerListeners, getContainerMouseListeners, getDescendantAt, getFocusTraversalPolicy, getGraphics, getLength, getNamedComponent, indexOf, insert, invalidate, isAncestor, isDoubleBuffered, iterator, layout, load, mouseClick, mouseDown, mouseMove, mouseOut, mouseUp, mouseWheel, move, paint, remove, removeAll, repaint, requestFocus, setDoubleBuffered, setEventDispatchThreadChecker, setFocusTraversalPolicy, setParent, setVisible, store, transferFocus, update
-
Methods inherited from class org.apache.pivot.wtk.Component
checkSkin, clearFocus, contains, copyStyle, copyStyle, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseOver, offsetToScreen, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
-
-
-
-
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, ornull
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, ornull
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.
-
getFormListeners
public ListenerList<FormListener> getFormListeners()
- Returns:
- The form listener list.
-
getFormAttributeListeners
public ListenerList<FormAttributeListener> getFormAttributeListeners()
- Returns:
- The form attribute listener list.
-
getSection
public static Form.Section getSection(Component component)
Finds theForm.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 theForm.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)
-
-