com.vaadin.ui
Class AbstractComponent

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
All Implemented Interfaces:
MethodEventSource, ClientConnector, Sizeable, com.vaadin.shared.Connector, Component, java.io.Serializable
Direct Known Subclasses:
AbstractColorPicker, AbstractComponentContainer, AbstractEmbedded, AbstractField, AbstractJavaScriptComponent, AbstractMedia, AbstractSingleComponentContainer, Button, Calendar, ColorPickerGradient, ColorPickerGrid, CustomComponent, Embedded, Label, Link, MenuBar, PopupView, Upload

public abstract class AbstractComponent
extends AbstractClientConnector
implements Component

An abstract class that defines default implementation for the Component interface. Basic UI components that are not derived from an external component can inherit this class to easily qualify as Vaadin components. Most components in Vaadin do just that.

Since:
3.0
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
 
Field Summary
 
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
AbstractComponent()
          Constructs a new Component.
 
Method Summary
 void addListener(Component.Listener listener)
          Registers a new (generic) component event listener for the component.
 void addShortcutListener(ShortcutListener shortcut)
           
 void addStyleName(java.lang.String style)
          Adds one or more style names to this component.
 void attach()
          Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).
 void beforeClientResponse(boolean initial)
          Called before the shared state and RPC invocations are sent to the client.
 void detach()
          Notifies the connector that it is detached from its VaadinSession.
<T extends HasComponents>
T
findAncestor(java.lang.Class<T> parentType)
          Returns the closest ancestor with the given type.
protected  void fireComponentErrorEvent()
          Emits the component error event.
protected  void fireComponentEvent()
          Emits the component event.
protected  void focus()
          Sets the focus for this component if the component is Focusable.
protected  ActionManager getActionManager()
          Gets the ActionManager used to manage the ShortcutListeners added to this Field.
 java.lang.String getCaption()
          Gets the caption of the component.
 ErrorMessage getComponentError()
          Gets the component's error message.
 java.lang.Object getData()
          Gets the application specific data.
 java.lang.String getDebugId()
          Deprecated. As of 7.0. Use getId()
 java.lang.String getDescription()
           Gets the components description, used in tooltips and can be displayed directly in certain other components such as forms.
 ErrorMessage getErrorMessage()
          Gets the error message for this component.
 float getHeight()
          Gets the height of the object.
 Sizeable.Unit getHeightUnits()
          Gets the height property units.
 Resource getIcon()
          Gets the icon resource of the component.
 java.lang.String getId()
          Gets currently set debug identifier
 java.util.Locale getLocale()
          Gets the locale of the component.
 HasComponents getParent()
          Gets the parent component of the component.
 java.lang.String getPrimaryStyleName()
          Gets the primary style name of the component.
protected  com.vaadin.shared.AbstractComponentState getState()
          Returns the shared state bean with information to be sent from the server to the client.
protected  com.vaadin.shared.AbstractComponentState getState(boolean markAsDirty)
          Returns the shared state for this connector.
 java.lang.String getStyleName()
          Gets all user-defined CSS style names of a component.
 float getWidth()
          Gets the width of the object.
 Sizeable.Unit getWidthUnits()
          Gets the width property units.
 boolean isConnectorEnabled()
          Checks if the communicator is enabled.
 boolean isEnabled()
          Tests whether the component is enabled or not.
 boolean isImmediate()
           
protected  boolean isOrHasAncestor(Component content)
          Determine whether a content component is equal to, or the ancestor of this component.
 boolean isReadOnly()
          Tests whether the component is in the read-only mode.
 boolean isVisible()
          Tests the visibility property of the component.
 void removeListener(Component.Listener listener)
          Removes a previously registered component event listener from this component.
 void removeShortcutListener(ShortcutListener shortcut)
           
 void removeStyleName(java.lang.String style)
          Removes one or more style names from component.
 void setCaption(java.lang.String caption)
          Sets the component's caption String.
 void setComponentError(ErrorMessage componentError)
          Sets the component's error message.
 void setData(java.lang.Object data)
          Sets the data object, that can be used for any application specific data.
 void setDebugId(java.lang.String id)
          Deprecated. As of 7.0. Use setId(String)
 void setDescription(java.lang.String description)
          Sets the component's description.
 void setEnabled(boolean enabled)
          Enables or disables the component.
 void setHeight(float height, Sizeable.Unit unit)
          Sets the height of the object.
 void setHeight(java.lang.String height)
          Sets the height of the component using String presentation.
 void setHeightUndefined()
          Clears any defined height
 void setIcon(Resource icon)
          Sets the component's icon.
 void setId(java.lang.String id)
          Adds an unique id for component that is used in the client-side for testing purposes.
 void setImmediate(boolean immediate)
          Sets the component's immediate mode to the specified status.
 void setLocale(java.util.Locale locale)
          Sets the locale of this component.
 void setParent(HasComponents parent)
          Sets the parent connector of the component.
 void setPrimaryStyleName(java.lang.String style)
          Changes the primary style name of the component.
 void setReadOnly(boolean readOnly)
          Sets the read-only mode of the component to the specified mode.
 void setSizeFull()
          Sets the size to 100% x 100%.
 void setSizeUndefined()
          Clears any size settings.
 void setStyleName(java.lang.String style)
          Sets one or more user-defined style names of the component, replacing any previous user-defined styles.
 void setVisible(boolean visible)
          Sets the visibility of the component.
 void setWidth(float width, Sizeable.Unit unit)
          Sets the width of the object.
 void setWidth(java.lang.String width)
          Sets the width of the component using String presentation.
 void setWidthUndefined()
          Clears any defined width
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
getUI
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 

Constructor Detail

AbstractComponent

public AbstractComponent()
Constructs a new Component.

Method Detail

setId

public void setId(java.lang.String id)
Description copied from interface: Component
Adds an unique id for component that is used in the client-side for testing purposes. Keeping identifiers unique is the responsibility of the programmer.

Specified by:
setId in interface Component
Parameters:
id - An alphanumeric id

getId

public java.lang.String getId()
Description copied from interface: Component
Gets currently set debug identifier

Specified by:
getId in interface Component
Returns:
current id, null if not set

setDebugId

@Deprecated
public void setDebugId(java.lang.String id)
Deprecated. As of 7.0. Use setId(String)


getDebugId

@Deprecated
public java.lang.String getDebugId()
Deprecated. As of 7.0. Use getId()


getStyleName

public java.lang.String getStyleName()
Description copied from interface: Component
Gets all user-defined CSS style names of a component. If the component has multiple style names defined, the return string is a space-separated list of style names. Built-in style names defined in Vaadin or GWT are not returned.

The style names are returned only in the basic form in which they were added; each user-defined style name shows as two CSS style class names in the rendered HTML: one as it was given and one prefixed with the component-specific style name. Only the former is returned.

Specified by:
getStyleName in interface Component
Returns:
the style name or a space-separated list of user-defined style names of the component
See Also:
Component.setStyleName(String), Component.addStyleName(String), Component.removeStyleName(String)

setStyleName

public void setStyleName(java.lang.String style)
Description copied from interface: Component
Sets one or more user-defined style names of the component, replacing any previous user-defined styles. Multiple styles can be specified as a space-separated list of style names. The style names must be valid CSS class names and should not conflict with any built-in style names in Vaadin or GWT.
 Label label = new Label("This text has a lot of style");
 label.setStyleName("myonestyle myotherstyle");
 

Each style name will occur in two versions: one as specified and one that is prefixed with the style name of the component. For example, if you have a Button component and give it "mystyle" style, the component will have both "mystyle" and "v-button-mystyle" styles. You could then style the component either with:

 .myonestyle {background: blue;}
 

or

 .v-button-myonestyle {background: blue;}
 

It is normally a good practice to use addStyleName() rather than this setter, as different software abstraction layers can then add their own styles without accidentally removing those defined in other layers.

This method will trigger a RepaintRequestEvent.

Specified by:
setStyleName in interface Component
Parameters:
style - the new style or styles of the component as a space-separated list
See Also:
Component.getStyleName(), Component.addStyleName(String), Component.removeStyleName(String)

setPrimaryStyleName

public void setPrimaryStyleName(java.lang.String style)
Description copied from interface: Component
Changes the primary style name of the component.

The primary style name identifies the component when applying the CSS theme to the Component. By changing the style name all CSS rules targeted for that style name will no longer apply, and might result in the component not working as intended.

To preserve the original style of the component when changing to a new primary style you should make your new primary style inherit the old primary style using the SASS @include directive. See more in the SASS tutorials.

Specified by:
setPrimaryStyleName in interface Component
Parameters:
style - The new primary style name

getPrimaryStyleName

public java.lang.String getPrimaryStyleName()
Description copied from interface: Component
Gets the primary style name of the component. See Component.setPrimaryStyleName(String) for a better description of the primary stylename.

Specified by:
getPrimaryStyleName in interface Component

addStyleName

public void addStyleName(java.lang.String style)
Description copied from interface: Component
Adds one or more style names to this component. Multiple styles can be specified as a space-separated list of style names. The style name will be rendered as a HTML class name, which can be used in a CSS definition.
 Label label = new Label("This text has style");
 label.addStyleName("mystyle");
 

Each style name will occur in two versions: one as specified and one that is prefixed wil the style name of the component. For example, if you have a Button component and give it "mystyle" style, the component will have both "mystyle" and "v-button-mystyle" styles. You could then style the component either with:

 .mystyle {font-style: italic;}
 

or

 .v-button-mystyle {font-style: italic;}
 

This method will trigger a RepaintRequestEvent.

Specified by:
addStyleName in interface Component
Parameters:
style - the new style to be added to the component
See Also:
Component.getStyleName(), Component.setStyleName(String), Component.removeStyleName(String)

removeStyleName

public void removeStyleName(java.lang.String style)
Description copied from interface: Component
Removes one or more style names from component. Multiple styles can be specified as a space-separated list of style names.

The parameter must be a valid CSS style name. Only user-defined style names added with addStyleName() or setStyleName() can be removed; built-in style names defined in Vaadin or GWT can not be removed.

* This method will trigger a RepaintRequestEvent.

Specified by:
removeStyleName in interface Component
Parameters:
style - the style name or style names to be removed
See Also:
Component.getStyleName(), Component.setStyleName(String), Component.addStyleName(String)

getCaption

public java.lang.String getCaption()
Description copied from interface: Component
Gets the caption of the component.

See Component.setCaption(String) for a detailed description of the caption.

Specified by:
getCaption in interface Component
Returns:
the caption of the component or null if the caption is not set.
See Also:
Component.setCaption(String)

setCaption

public void setCaption(java.lang.String caption)
Sets the component's caption String. Caption is the visible name of the component. This method will trigger a RepaintRequestEvent.

Specified by:
setCaption in interface Component
Parameters:
caption - the new caption String for the component.

getLocale

public java.util.Locale getLocale()
Description copied from interface: Component
Gets the locale of the component.

If a component does not have a locale set, the locale of its parent is returned, and so on. Eventually, if no parent has locale set, the locale of the application is returned. If the application does not have a locale set, it is determined by Locale.getDefault().

As the component must be attached before its locale can be acquired, using this method in the internationalization of component captions, etc. is generally not feasible. For such use case, we recommend using an otherwise acquired reference to the application locale.

Specified by:
getLocale in interface Component
Returns:
Locale of this component or null if the component and none of its parents has a locale set and the component is not yet attached to an application.

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale of this component.
 // Component for which the locale is meaningful
 InlineDateField date = new InlineDateField("Datum");
 
 // German language specified with ISO 639-1 language
 // code and ISO 3166-1 alpha-2 country code.
 date.setLocale(new Locale("de", "DE"));
 
 date.setResolution(DateField.RESOLUTION_DAY);
 layout.addComponent(date);
 

Parameters:
locale - the locale to become this component's locale.

getIcon

public Resource getIcon()
Description copied from interface: Component
Gets the icon resource of the component.

See Component.setIcon(Resource) for a detailed description of the icon.

Specified by:
getIcon in interface Component
Returns:
the icon resource of the component or null if the component has no icon
See Also:
Component.setIcon(Resource)

setIcon

public void setIcon(Resource icon)
Sets the component's icon. This method will trigger a RepaintRequestEvent.

Specified by:
setIcon in interface Component
Parameters:
icon - the icon to be shown with the component's caption.
See Also:
Component.getIcon(), Component.setCaption(String)

isEnabled

public boolean isEnabled()
Description copied from interface: Component
Tests whether the component is enabled or not. A user can not interact with disabled components. Disabled components are rendered in a style that indicates the status, usually in gray color. Children of a disabled component are also disabled. Components are enabled by default.

As a security feature, all updates for disabled components are blocked on the server-side.

Note that this method only returns the status of the component and does not take parents into account. Even though this method returns true the component can be disabled to the user if a parent is disabled.

Specified by:
isEnabled in interface Component
Returns:
true if the component and its parent are enabled, false otherwise.
See Also:
VariableOwner.isEnabled()

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: Component
Enables or disables the component. The user can not interact disabled components, which are shown with a style that indicates the status, usually shaded in light gray color. Components are enabled by default.
 Button enabled = new Button("Enabled");
 enabled.setEnabled(true); // The default
 layout.addComponent(enabled);
 
 Button disabled = new Button("Disabled");
 disabled.setEnabled(false);
 layout.addComponent(disabled);
 

This method will trigger a RepaintRequestEvent for the component and, if it is a ComponentContainer, for all its children recursively.

Specified by:
setEnabled in interface Component
Parameters:
enabled - a boolean value specifying if the component should be enabled or not

isConnectorEnabled

public boolean isConnectorEnabled()
Description copied from interface: ClientConnector
Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.

Specified by:
isConnectorEnabled in interface ClientConnector
Overrides:
isConnectorEnabled in class AbstractClientConnector
Returns:
true if the connector can receive messages, false otherwise

isImmediate

public boolean isImmediate()

setImmediate

public void setImmediate(boolean immediate)
Sets the component's immediate mode to the specified status.

Parameters:
immediate - the boolean value specifying if the component should be in the immediate mode after the call.

isVisible

public boolean isVisible()
Description copied from interface: Component
Tests the visibility property of the component.

Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent. Making a component invisible through this property can alter the positioning of other components.

A component is visible only if all its parents are also visible. This is not checked by this method though, so even if this method returns true, the component can be hidden from the user because a parent is set to invisible.

Specified by:
isVisible in interface Component
Returns:
true if the component has been set to be visible in the user interface, false if not
See Also:
Component.setVisible(boolean), Component.attach()

setVisible

public void setVisible(boolean visible)
Description copied from interface: Component
Sets the visibility of the component.

Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.

 TextField readonly = new TextField("Read-Only");
 readonly.setValue("You can't see this!");
 readonly.setVisible(false);
 layout.addComponent(readonly);
 

A component is visible only if all of its parents are also visible. If a component is explicitly set to be invisible, changes in the visibility of its parents will not change the visibility of the component.

Specified by:
setVisible in interface Component
Parameters:
visible - the boolean value specifying if the component should be visible after the call or not.
See Also:
Component.isVisible()

getDescription

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

Gets the components description, used in tooltips and can be displayed directly in certain other components such as forms. The description can be used to briefly describe the state of the component to the user. The description string may contain certain XML tags:

Tag Description Example
<b> bold bold text
<i> italic italic text
<u> underlined underlined text
<br> linebreak N/A
<ul>
<li>item1
<li>item1
</ul>
item list
  • item1
  • item2

These tags may be nested.

Specified by:
getDescription in interface Component
Returns:
component's description String

setDescription

public void setDescription(java.lang.String description)
Sets the component's description. See getDescription() for more information on what the description is. This method will trigger a RepaintRequestEvent. The description is displayed as HTML in tooltips or directly in certain components so care should be taken to avoid creating the possibility for HTML injection and possibly XSS vulnerabilities.

Parameters:
description - the new description string for the component.

getParent

public HasComponents getParent()
Description copied from interface: Component
Gets the parent component of the component.

Components can be nested but a component can have only one parent. A component that contains other components, that is, can be a parent, should usually inherit the ComponentContainer interface.

Specified by:
getParent in interface ClientConnector
Specified by:
getParent in interface com.vaadin.shared.Connector
Specified by:
getParent in interface Component
Returns:
the parent component

setParent

public void setParent(HasComponents parent)
Description copied from interface: Component
Sets the parent connector of the component.

This method automatically calls Component.attach() if the component becomes attached to the session, regardless of whether it was attached previously. Conversely, if the component currently is attached to the session, ClientConnector.detach() is called for the connector before attaching it to a new parent.

This method is rarely called directly. ComponentContainer.addComponent(Component) or a HasComponents specific method is normally used for adding components to a parent and the used method will call this method implicitly.

Specified by:
setParent in interface Component
Parameters:
parent - the parent connector

findAncestor

public <T extends HasComponents> T findAncestor(java.lang.Class<T> parentType)
Returns the closest ancestor with the given type.

To find the Window that contains the component, use Window w = getParent(Window.class);

Type Parameters:
T - The type of the ancestor
Parameters:
parentType - The ancestor class we are looking for
Returns:
The first ancestor that can be assigned to the given class. Null if no ancestor with the correct type could be found.

getErrorMessage

public ErrorMessage getErrorMessage()
Gets the error message for this component.

Returns:
ErrorMessage containing the description of the error state of the component or null, if the component contains no errors. Extending classes should override this method if they support other error message types such as validation errors or buffering errors. The returned error message contains information about all the errors.

getComponentError

public ErrorMessage getComponentError()
Gets the component's error message.

Returns:
the component's error message.

setComponentError

public void setComponentError(ErrorMessage componentError)
Sets the component's error message. The message may contain certain XML tags, for more information see

Parameters:
componentError - the new ErrorMessage of the component.

isReadOnly

public boolean isReadOnly()
Description copied from interface: Component
Tests whether the component is in the read-only mode. The user can not change the value of a read-only component. As only Field components normally have a value that can be input or changed by the user, this is mostly relevant only to field components, though not restricted to them.

Notice that the read-only mode only affects whether the user can change the value of the component; it is possible to, for example, scroll a read-only table.

The method will return true if the component or any of its parents is in the read-only mode.

Specified by:
isReadOnly in interface Component
Returns:
true if the component or any of its parents is in read-only mode, false if not.
See Also:
Component.setReadOnly(boolean)

setReadOnly

public void setReadOnly(boolean readOnly)
Description copied from interface: Component
Sets the read-only mode of the component to the specified mode. The user can not change the value of a read-only component.

As only Field components normally have a value that can be input or changed by the user, this is mostly relevant only to field components, though not restricted to them.

Notice that the read-only mode only affects whether the user can change the value of the component; it is possible to, for example, scroll a read-only table.

This method will trigger a RepaintRequestEvent.

Specified by:
setReadOnly in interface Component
Parameters:
readOnly - a boolean value specifying whether the component is put read-only mode or not

attach

public void attach()
Description copied from interface: ClientConnector
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).

The caller of this method is #setParent(ClientConnector) if the parent is itself already attached to the session. If not, the parent will call the ClientConnector.attach() for all its children when it is attached to the session. This method is always called before the connector's data is sent to the client-side for the first time.

The attachment logic is implemented in AbstractClientConnector.

Specified by:
attach in interface ClientConnector
Specified by:
attach in interface Component
Overrides:
attach in class AbstractClientConnector

detach

public void detach()
Description copied from class: AbstractClientConnector
Notifies the connector that it is detached from its VaadinSession.

The caller of this method is #setParent(ClientConnector) if the parent is in the session. When the parent is detached from the session it is its responsibility to call ClientConnector.detach() for each of its children.

The AbstractClientConnector.getSession() and AbstractClientConnector.getUI() methods might return null after this method is called.

Specified by:
detach in interface ClientConnector
Overrides:
detach in class AbstractClientConnector

focus

protected void focus()
Sets the focus for this component if the component is Focusable.


getState

protected com.vaadin.shared.AbstractComponentState getState()
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

Overrides:
getState in class AbstractClientConnector
Returns:
updated component shared state
Since:
7.0

getState

protected com.vaadin.shared.AbstractComponentState getState(boolean markAsDirty)
Description copied from class: AbstractClientConnector
Returns the shared state for this connector.

Overrides:
getState in class AbstractClientConnector
Parameters:
markAsDirty - true if the connector should automatically be marked dirty, false otherwise
Returns:
The shared state for this connector. Never null.
See Also:
AbstractClientConnector.getState()

beforeClientResponse

public void beforeClientResponse(boolean initial)
Description copied from interface: ClientConnector
Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.

This method must not alter the component hierarchy in any way. Calling ClientConnector.markAsDirty() from this method will have no effect.

Specified by:
beforeClientResponse in interface ClientConnector
Overrides:
beforeClientResponse in class AbstractClientConnector
Parameters:
initial - true if the client-side connector will be created and initialized after this method has been invoked. false if there is already an initialized client-side connector.

addListener

public void addListener(Component.Listener listener)
Description copied from interface: Component
Registers a new (generic) component event listener for the component.
 class Listening extends CustomComponent implements Listener {
     // Stored for determining the source of an event
     Button ok;
 
     Label status; // For displaying info about the event
 
     public Listening() {
         VerticalLayout layout = new VerticalLayout();
 
         // Some miscellaneous component
         TextField name = new TextField("Say it all here");
         name.addListener(this);
         name.setImmediate(true);
         layout.addComponent(name);
 
         // Handle button clicks as generic events instead
         // of Button.ClickEvent events
         ok = new Button("OK");
         ok.addListener(this);
         layout.addComponent(ok);
 
         // For displaying information about an event
         status = new Label("");
         layout.addComponent(status);
 
         setCompositionRoot(layout);
     }
 
     public void componentEvent(Event event) {
         // Act according to the source of the event
         if (event.getSource() == ok)
             getWindow().showNotification("Click!");
 
         status.setValue("Event from " + event.getSource().getClass().getName()
                 + ": " + event.getClass().getName());
     }
 }
 
 Listening listening = new Listening();
 layout.addComponent(listening);
 

Specified by:
addListener in interface Component
Parameters:
listener - the new Listener to be registered.
See Also:
Component.Event, Component.removeListener(Listener)

removeListener

public void removeListener(Component.Listener listener)
Description copied from interface: Component
Removes a previously registered component event listener from this component.

Specified by:
removeListener in interface Component
Parameters:
listener - the listener to be removed.
See Also:
Component.addListener(Listener)

fireComponentEvent

protected void fireComponentEvent()
Emits the component event. It is transmitted to all registered listeners interested in such events.


fireComponentErrorEvent

protected void fireComponentErrorEvent()
Emits the component error event. It is transmitted to all registered listeners interested in such events.


setData

public void setData(java.lang.Object data)
Sets the data object, that can be used for any application specific data. The component does not use or modify this data.

Parameters:
data - the Application specific data.
Since:
3.1

getData

public java.lang.Object getData()
Gets the application specific data. See setData(Object).

Returns:
the Application specific data set with setData function.
Since:
3.1

getHeight

public float getHeight()
Description copied from interface: Sizeable
Gets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
getHeight in interface Sizeable
Returns:
height of the object in units specified by heightUnits property.

getHeightUnits

public Sizeable.Unit getHeightUnits()
Description copied from interface: Sizeable
Gets the height property units.

Specified by:
getHeightUnits in interface Sizeable
Returns:
units used in height property.

getWidth

public float getWidth()
Description copied from interface: Sizeable
Gets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
getWidth in interface Sizeable
Returns:
width of the object in units specified by widthUnits property.

getWidthUnits

public Sizeable.Unit getWidthUnits()
Description copied from interface: Sizeable
Gets the width property units.

Specified by:
getWidthUnits in interface Sizeable
Returns:
units used in width property.

setHeight

public void setHeight(float height,
                      Sizeable.Unit unit)
Description copied from interface: Sizeable
Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setHeight in interface Sizeable
Parameters:
height - the height of the object.
unit - the unit used for the width.

setSizeFull

public void setSizeFull()
Description copied from interface: Sizeable
Sets the size to 100% x 100%.

Specified by:
setSizeFull in interface Sizeable

setSizeUndefined

public void setSizeUndefined()
Description copied from interface: Sizeable
Clears any size settings.

Specified by:
setSizeUndefined in interface Sizeable

setWidthUndefined

public void setWidthUndefined()
Description copied from interface: Sizeable
Clears any defined width

Specified by:
setWidthUndefined in interface Sizeable

setHeightUndefined

public void setHeightUndefined()
Description copied from interface: Sizeable
Clears any defined height

Specified by:
setHeightUndefined in interface Sizeable

setWidth

public void setWidth(float width,
                     Sizeable.Unit unit)
Description copied from interface: Sizeable
Sets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setWidth in interface Sizeable
Parameters:
width - the width of the object.
unit - the unit used for the width.

setWidth

public void setWidth(java.lang.String width)
Description copied from interface: Sizeable
Sets the width of the component using String presentation. String presentation is similar to what is used in Cascading Style Sheets. Size can be length or percentage of available size. The empty string ("") or null will unset the width and set the units to pixels. See CSS specification for more details.

Specified by:
setWidth in interface Sizeable
Parameters:
width - in CSS style string representation, null or empty string to reset

setHeight

public void setHeight(java.lang.String height)
Description copied from interface: Sizeable
Sets the height of the component using String presentation. String presentation is similar to what is used in Cascading Style Sheets. Size can be length or percentage of available size. The empty string ("") or null will unset the height and set the units to pixels. See CSS specification for more details.

Specified by:
setHeight in interface Sizeable
Parameters:
height - in CSS style string representation

getActionManager

protected ActionManager getActionManager()
Gets the ActionManager used to manage the ShortcutListeners added to this Field.

Returns:
the ActionManager in use

addShortcutListener

public void addShortcutListener(ShortcutListener shortcut)

removeShortcutListener

public void removeShortcutListener(ShortcutListener shortcut)

isOrHasAncestor

protected boolean isOrHasAncestor(Component content)
Determine whether a content component is equal to, or the ancestor of this component.

Parameters:
content - the potential ancestor element
Returns:
true if the relationship holds


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.