nextapp.echo
Class AbstractComponent

java.lang.Object
  extended by nextapp.echo.AbstractComponent
All Implemented Interfaces:
java.io.Serializable, Component
Direct Known Subclasses:
AbstractButton, AbstractPane, Beep, ClientSideComponentSelector, Column, Container, CustomComponent, Download, DragWrapper, DropWrapper, DummyComponent, EmbeddedPane, ExternalEventMonitor, Filler, HourGlass, KeyActionCommand, Label, ListBox, MockComponent, NativeCheckBox, OnLoadScriptOnceComponent, Panel, PdfBookmarkComponent, PdfReportComponent, PopWrapper, PrintRequest, Row, SelectField, Table, TableHeader, TextComponent, Timer, Timer, UploadSelect, Window

public abstract class AbstractComponent
extends java.lang.Object
implements java.io.Serializable, Component

A base class from which all Components are derived.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
AbstractComponent()
          Default Component constructor.
 
Method Summary
 void add(Component c)
          Adds the specified Component at the end of this Component's children.
 void add(Component c, int n)
          Adds the specified Component as the nth child All component add operations use this method to add components.
 void addHierarchyListener(HierarchyListener l)
          Adds a hierarchy listener to be notified when this component's state in the hierarchy changes.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a property change listener to this component.
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
          Reports a bound property change.
 void firePropertyChange(java.lang.String propertyName, char oldValue, char newValue)
          Reports a bound property change.
 void firePropertyChange(java.lang.String propertyName, double oldValue, double newValue)
          Reports a bound property change.
 void firePropertyChange(java.lang.String propertyName, float oldValue, float newValue)
          Reports a bound property change.
 void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
          Reports a bound property change.
 void firePropertyChange(java.lang.String propertyName, long oldValue, long newValue)
          Reports a bound property change.
 void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Reports a bound property change.
 Color getBackground()
          Returns the background color of the component.
 java.lang.String getClientId()
           Gets the reuseable Id, this is used to keep component peer id constant over show/hide cycles.
 Component getComponent(int n)
          Gets the nth immediate child component.
 int getComponentCount()
          Returns the number of immediate child components.
 Component[] getComponents()
          Returns an array of all immediate child components.
 EchoInstance getEchoInstance()
          Returns the EchoInstance object to which this component belongs, or null if it is not bound to any instance.
 Font getFont()
          Returns the font.
 Color getForeground()
          Returns the foreground of the component.
 java.lang.Object getIdentifier()
          Returns the identifier for this component.
 EventListenerList getListenerList()
           
 java.util.Locale getLocale()
          Returns the locale of the component.
 Component getParent()
          Returns the parent component.
 int indexOf(Component c)
          Returns the index of the specified component if it a child of this Component, or -1 if it is not.
 void init()
          Called exactly one time when a component is registered to a hierarchy for the first time.
 boolean isAncestorOf(Component c)
          Determines if this component is an ancestor of the specified component.
static boolean isDifferent(java.lang.Object o1, java.lang.Object o2)
           
 boolean isEnabled()
          Returns true if the component is enabled.
 boolean isFocused()
          Returns true if the component is focused.
 boolean isRecursivelyVisible()
          Returns true if the component and all of its ancestors are visible.
 boolean isRegistered()
          Returns true if the component is registered to an application.
 boolean isSelectableForScriptRecorder()
           
 boolean isShowing()
          Returns true if the component is registered and all of its ancestors are visible.
 boolean isVisible()
          Returns the component's visibility state.
 void processHierarchyEvent(long changeFlags, Component changed, Component changedParent)
          Notifies descendant components of a hierarchy event.
 void remove(Component c)
          Removes the specified child component.
 void remove(int n)
          Removes the component at the given index.
 void removeAll()
          Removes all child Components.
 void removeHierarchyListener(HierarchyListener l)
          Removes a hierarchy listener from being notified when this component's state in the hierarchy changes.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a property change listener from this component.
 void setBackground(Color newValue)
          Sets the background color of the component.
 void setClientId(java.lang.String reusableId)
           Sets the reuseable Id, this is used to keep component peer id constant over show/hide cycles.
 void setEnabled(boolean newValue)
          Sets whether the component is enabled.
 void setFocused(boolean newValue)
          Sets whether the component is focused.
 void setFont(Font newValue)
          Sets the font of the component.
 void setForeground(Color newValue)
          Sets the foreground color of the component.
 void setIdentifier(java.lang.Object newValue)
          Sets the identifier for this component.
 void setLocale(java.util.Locale newValue)
          Sets the locale of the component.
 void setParent(Component parent)
           
 void setRegistered(boolean registered)
          Sets the registration state of the component and children beneath it within the hierarchy.
 void setSelectableForScriptRecorder(boolean b)
           
 void setVisible(boolean newValue)
          Sets the component visible or invisible.
 void update()
          Forces the component to be re-rendered immediately.
 void validate()
          Validates this component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractComponent

public AbstractComponent()
Default Component constructor.

Method Detail

add

public void add(Component c)
Description copied from interface: Component
Adds the specified Component at the end of this Component's children.

Specified by:
add in interface Component
Parameters:
c - The child component to add.

add

public void add(Component c,
                int n)
Description copied from interface: Component
Adds the specified Component as the nth child All component add operations use this method to add components. Components that require notification of all child additions should override this method (making sure to call the superclass' implementation).

Specified by:
add in interface Component
Parameters:
c - The child component to add.
n - The index at which to add the child component, or -1 to add the component at the end.

addHierarchyListener

public void addHierarchyListener(HierarchyListener l)
Description copied from interface: Component
Adds a hierarchy listener to be notified when this component's state in the hierarchy changes.

Specified by:
addHierarchyListener in interface Component
Parameters:
l - The HierarchyListener to add.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: Component
Adds a property change listener to this component.

Specified by:
addPropertyChangeListener in interface Component
Parameters:
l - The listener to add.

applyStyle

public void applyStyle(Style style)
Description copied from interface: Component
Sets stylistic properties of this component based on a Style object. The version of this method in Component will set foreground and background colors and the font from the style if they are present. Components should override this method if they allow more properties to be set from a style object, and should call super.applyStyle() if necessary.

Specified by:
applyStyle in interface Component
Parameters:
style - The style object from which to retrieve properties for this Component.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               boolean oldValue,
                               boolean newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               char oldValue,
                               char newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               double oldValue,
                               double newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               float oldValue,
                               float newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               int oldValue,
                               int newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               long oldValue,
                               long newValue)
Description copied from interface: Component
Reports a bound property change.

Specified by:
firePropertyChange in interface Component
Parameters:
propertyName - The name of the changed property.
oldValue - The previous value of the property.
newValue - The present value of the property.

getBackground

public Color getBackground()
Description copied from interface: Component
Returns the background color of the component.

Specified by:
getBackground in interface Component
Returns:
The background color of the component.

getComponent

public Component getComponent(int n)
Description copied from interface: Component
Gets the nth immediate child component.

Specified by:
getComponent in interface Component
Parameters:
n - The index of the component to retrieve.
Returns:
The component at index n.

getComponentCount

public int getComponentCount()
Description copied from interface: Component
Returns the number of immediate child components.

Specified by:
getComponentCount in interface Component
Returns:
The number of immediate child components.

getComponents

public Component[] getComponents()
Description copied from interface: Component
Returns an array of all immediate child components.

Specified by:
getComponents in interface Component
Returns:
An array of all immediate child components.

getEchoInstance

public EchoInstance getEchoInstance()
Description copied from interface: Component
Returns the EchoInstance object to which this component belongs, or null if it is not bound to any instance.

Specified by:
getEchoInstance in interface Component
Returns:
The EchoInstance object to which this component belongs.

getFont

public Font getFont()
Description copied from interface: Component
Returns the font.

Specified by:
getFont in interface Component
Returns:
The font of the component.

getForeground

public Color getForeground()
Description copied from interface: Component
Returns the foreground of the component.

Specified by:
getForeground in interface Component
Returns:
The foreground of the component.

getIdentifier

public java.lang.Object getIdentifier()
Description copied from interface: Component
Returns the identifier for this component. Every component may have an identifier. Identifiers are provided as a convenience to the application developer, and are not used internally in any manner.

Specified by:
getIdentifier in interface Component
Returns:
The identifier for this component.

getLocale

public java.util.Locale getLocale()
Description copied from interface: Component
Returns the locale of the component. If the component does not have a locale, its ancestors will be queried for a locale. If no ancestors have locales set, the application instance's locale will be returned. If the component is not registered, the active application instance's will be returned.

Specified by:
getLocale in interface Component
Returns:
The locale for this component.

getParent

public Component getParent()
Description copied from interface: Component
Returns the parent component.

Specified by:
getParent in interface Component
Returns:
The parent component.

indexOf

public int indexOf(Component c)
Description copied from interface: Component
Returns the index of the specified component if it a child of this Component, or -1 if it is not.

Specified by:
indexOf in interface Component
Parameters:
c - The component to determine the index of.
Returns:
The index of the specified component.

init

public void init()
Called exactly one time when a component is registered to a hierarchy for the first time.

This method is intended to be overridden by applications that require constructor-like functionality of a Component but can only perform such functions after the component has been registered to a hierarchy. This is often necessary as application-specific and locale information are not available until registration occurs.

Developers overriding this method should ensure that super.init() is also invoked.

Specified by:
init in interface Component

isAncestorOf

public boolean isAncestorOf(Component c)
Description copied from interface: Component
Determines if this component is an ancestor of the specified component.

Specified by:
isAncestorOf in interface Component
Parameters:
c - The component to test for ancestry.
Returns:
true If this component is an ancestor of the specified component.

isEnabled

public boolean isEnabled()
Description copied from interface: Component
Returns true if the component is enabled.

Specified by:
isEnabled in interface Component
Returns:
True if the component is enabled.

isFocused

public boolean isFocused()
Description copied from interface: Component
Returns true if the component is focused.

Specified by:
isFocused in interface Component
Returns:
True if the component is focused.

isRecursivelyVisible

public boolean isRecursivelyVisible()
Returns true if the component and all of its ancestors are visible.

Specified by:
isRecursivelyVisible in interface Component
Returns:
True if the component and all of its ancestors are visible.

isRegistered

public final boolean isRegistered()
Description copied from interface: Component
Returns true if the component is registered to an application.

Specified by:
isRegistered in interface Component
Returns:
True if the component is registered to an application.

isShowing

public final boolean isShowing()
Description copied from interface: Component
Returns true if the component is registered and all of its ancestors are visible.

Specified by:
isShowing in interface Component
Returns:
True if the component is registered and all of its ancestors are visible.

isVisible

public final boolean isVisible()
Description copied from interface: Component
Returns the component's visibility state.

Specified by:
isVisible in interface Component
Returns:
The component's visibility state.

processHierarchyEvent

public void processHierarchyEvent(long changeFlags,
                                  Component changed,
                                  Component changedParent)
Notifies descendant components of a hierarchy event.

Specified by:
processHierarchyEvent in interface Component
Parameters:
changeFlags - The hierarchy event flags used to describe the changes.
changed - The component whose state in the hierarchy changed.
changedParent - The parent (or in some cases, former parent) of the component whose state in the hierarchy changed.

remove

public void remove(Component c)
Description copied from interface: Component
Removes the specified child component. All component remove operations use this method to remove components. Components that require notification of all child removals should override this method (making sure to call the superclass' implementation).

Specified by:
remove in interface Component
Parameters:
c - The child component to remove.

remove

public void remove(int n)
Description copied from interface: Component
Removes the component at the given index.

Specified by:
remove in interface Component
Parameters:
n - The index of the child component to remove.

removeAll

public void removeAll()
Description copied from interface: Component
Removes all child Components.

Specified by:
removeAll in interface Component

removeHierarchyListener

public void removeHierarchyListener(HierarchyListener l)
Description copied from interface: Component
Removes a hierarchy listener from being notified when this component's state in the hierarchy changes.

Specified by:
removeHierarchyListener in interface Component
Parameters:
l - The HierarchyListener to remove.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: Component
Removes a property change listener from this component.

Specified by:
removePropertyChangeListener in interface Component
Parameters:
l - The listener to be removed.

setBackground

public void setBackground(Color newValue)
Description copied from interface: Component
Sets the background color of the component.

Specified by:
setBackground in interface Component
Parameters:
newValue - The new background color of the component.

setEnabled

public void setEnabled(boolean newValue)
Description copied from interface: Component
Sets whether the component is enabled.

Specified by:
setEnabled in interface Component
Parameters:
newValue - True if the component is enabled.

setFocused

public void setFocused(boolean newValue)
Description copied from interface: Component
Sets whether the component is focused.

Specified by:
setFocused in interface Component
Parameters:
newValue - True if the component is to be focused.

setFont

public void setFont(Font newValue)
Description copied from interface: Component
Sets the font of the component.

Specified by:
setFont in interface Component
Parameters:
newValue - The new font of the component.

setForeground

public void setForeground(Color newValue)
Description copied from interface: Component
Sets the foreground color of the component.

Specified by:
setForeground in interface Component
Parameters:
newValue - The new foreground color of the component.

setIdentifier

public void setIdentifier(java.lang.Object newValue)
Description copied from interface: Component
Sets the identifier for this component. Every component may have an identifier. Identifiers are provided as a convenience to the application developer, and are not used internally in any manner.

Specified by:
setIdentifier in interface Component
Parameters:
newValue - The new identifier for this component.

setLocale

public void setLocale(java.util.Locale newValue)
Description copied from interface: Component
Sets the locale of the component.

Specified by:
setLocale in interface Component
Parameters:
newValue - The new locale for the component.

setRegistered

public void setRegistered(boolean registered)
Sets the registration state of the component and children beneath it within the hierarchy.

Specified by:
setRegistered in interface Component
Parameters:
registered - The new registration state.

setVisible

public void setVisible(boolean newValue)
Description copied from interface: Component
Sets the component visible or invisible.

Specified by:
setVisible in interface Component
Parameters:
newValue - The new visibility state of the component.

update

public void update()
Description copied from interface: Component
Forces the component to be re-rendered immediately. Fires a property change event indicating that any/all properties of the Component changed, forcing the container to re-render it.

Specified by:
update in interface Component

validate

public void validate()
Description copied from interface: Component
Validates this component. This method will be called by the application container before the component is rendered. This method should be overridden if the component needs to be updated before being rendered. Validation occurs from the top of the component hierarchy down. Overriding methods should take care to first call super.validate() to ensure the superclass is validated as well.

If components above this one in the hierarchy are modified by an overriding implementation of this method, those components WILL NOT be automatically revalidated. Thus, performing such operations in validate() is not inadvisable.

Specified by:
validate in interface Component

getClientId

public java.lang.String getClientId()
Description copied from interface: Component

Gets the reuseable Id, this is used to keep component peer id constant over show/hide cycles.

Specified by:
getClientId in interface Component

setClientId

public void setClientId(java.lang.String reusableId)
Description copied from interface: Component

Sets the reuseable Id, this is used to keep component peer id constant over show/hide cycles. Do not call from your application code !

Specified by:
setClientId in interface Component

isDifferent

public static boolean isDifferent(java.lang.Object o1,
                                  java.lang.Object o2)

getListenerList

public EventListenerList getListenerList()
Specified by:
getListenerList in interface Component

setParent

public void setParent(Component parent)
Specified by:
setParent in interface Component

isSelectableForScriptRecorder

public boolean isSelectableForScriptRecorder()
Specified by:
isSelectableForScriptRecorder in interface Component

setSelectableForScriptRecorder

public void setSelectableForScriptRecorder(boolean b)
Specified by:
setSelectableForScriptRecorder in interface Component