com.vaadin.ui
Class Panel

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractComponentContainer
              extended by com.vaadin.ui.Panel
All Implemented Interfaces:
Action.Container, Action.Notifier, MethodEventSource, Connector, ClientConnector, RpcTarget, Scrollable, Sizeable, Vaadin6Component, VariableOwner, Component, Component.Focusable, ComponentContainer, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, HasComponents, Serializable, Iterable<Component>, EventListener
Direct Known Subclasses:
Window

public class Panel
extends AbstractComponentContainer
implements Scrollable, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Action.Notifier, Component.Focusable, Vaadin6Component

Panel - a simple single component container.

Since:
3.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.VariableOwner
VariableOwner.ErrorEvent
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener
 
Field Summary
protected  ActionManager actionManager
          Keeps track of the Actions added to this component, and manages the painting and handling as well.
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
Panel()
          Creates a new empty panel.
Panel(ComponentContainer content)
          Creates a new empty panel which contains the given content.
Panel(String caption)
          Creates a new empty panel with caption.
Panel(String caption, ComponentContainer content)
          Creates a new empty panel with the given caption and content.
 
Method Summary
<T extends Action & Action.Listener>
void
addAction(T action)
           
 void addActionHandler(Action.Handler actionHandler)
          Registers a new action handler for this container
 void addComponent(Component c)
          Adds the component into this container.
 void addListener(MouseEvents.ClickListener listener)
          Add a click listener to the Panel.
 void changeVariables(Object source, Map<String,Object> variables)
          Called when one or more variables handled by the implementing class are changed.
 void componentAttachedToContainer(ComponentContainer.ComponentAttachEvent event)
          A new component is attached to container.
 void componentDetachedFromContainer(ComponentContainer.ComponentDetachEvent event)
          A component has been detached from container.
 void focus()
          Moves keyboard focus to the component.
protected  ActionManager getActionManager()
          Gets the ActionManager used to manage the ShortcutListeners added to this Field.
 int getComponentCount()
          Gets the number of children this ComponentContainer has.
 Iterator<Component> getComponentIterator()
          Gets the component container iterator for going through all the components in the container.
 ComponentContainer getContent()
          Returns the content of the Panel.
 int getScrollLeft()
          Gets scroll left offset.
 int getScrollTop()
          Gets scroll top offset.
 PanelState getState()
          Returns the shared state bean with information to be sent from the server to the client.
 int getTabIndex()
          Gets the tabulator index of the Focusable component.
 void paintContent(PaintTarget target)
           Paints the Paintable into a UIDL stream.
<T extends Action & Action.Listener>
void
removeAction(T action)
           
 void removeActionHandler(Action.Handler actionHandler)
          Removes a previously registered action handler for the contents of this container.
 void removeAllActionHandlers()
          Removes all action handlers
 void removeAllComponents()
          Removes all components from this container.
 void removeComponent(Component c)
          Removes the component from this container.
 void removeListener(MouseEvents.ClickListener listener)
          Remove a click listener from the Panel.
 void replaceComponent(Component oldComponent, Component newComponent)
          Replaces the component in the container with another one without changing position.
 void setCaption(String caption)
          Sets the caption of the panel.
 void setContent(ComponentContainer newContent)
          Set the content of the Panel.
 void setScrollLeft(int scrollLeft)
          Sets scroll left offset.
 void setScrollTop(int scrollTop)
          Sets scroll top offset.
 void setTabIndex(int tabIndex)
          Sets the tabulator index of the Focusable component.
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, isComponentVisible, iterator, moveComponentsFrom, removeListener, removeListener, setHeight, setVisible, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRoot, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setWidth, updateState
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
isEnabled, isImmediate
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, setVisible, updateState
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
detach, getExtensions, getStateType, isConnectorEnabled, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 

Field Detail

actionManager

protected ActionManager actionManager
Keeps track of the Actions added to this component, and manages the painting and handling as well.

Constructor Detail

Panel

public Panel()
Creates a new empty panel. A VerticalLayout is used as content.


Panel

public Panel(ComponentContainer content)
Creates a new empty panel which contains the given content. The content cannot be null.

Parameters:
content - the content for the panel.

Panel

public Panel(String caption)
Creates a new empty panel with caption. Default layout is used.

Parameters:
caption - the caption used in the panel (HTML/XHTML).

Panel

public Panel(String caption,
             ComponentContainer content)
Creates a new empty panel with the given caption and content.

Parameters:
caption - the caption of the panel (HTML/XHTML).
content - the content used in the panel.
Method Detail

setCaption

public void setCaption(String caption)
Sets the caption of the panel. Note that the caption is interpreted as HTML/XHTML and therefore care should be taken not to enable HTML injection and XSS attacks using panel captions. This behavior may change in future versions.

Specified by:
setCaption in interface Component
Overrides:
setCaption in class AbstractComponent
Parameters:
caption - the new caption String for the component.
See Also:
AbstractComponent.setCaption(String)

getContent

public ComponentContainer getContent()
Returns the content of the Panel.

Returns:

setContent

public void setContent(ComponentContainer newContent)
Set the content of the Panel. If null is given as the new content then a layout is automatically created and set as the content.

Parameters:
content - The new content

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from interface: Vaadin6Component

Paints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.

It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.

Specified by:
paintContent in interface Vaadin6Component
Parameters:
target - the target UIDL stream where the component should paint itself to.
Throws:
PaintException - if the paint operation failed.

addComponent

public void addComponent(Component c)
Adds the component into this container.

Specified by:
addComponent in interface ComponentContainer
Overrides:
addComponent in class AbstractComponentContainer
Parameters:
c - the component to be added.
See Also:
AbstractComponentContainer.addComponent(com.vaadin.ui.Component)

removeComponent

public void removeComponent(Component c)
Removes the component from this container.

Specified by:
removeComponent in interface ComponentContainer
Overrides:
removeComponent in class AbstractComponentContainer
Parameters:
c - The component to be removed.
See Also:
AbstractComponentContainer.removeComponent(com.vaadin.ui.Component)

getComponentIterator

public Iterator<Component> getComponentIterator()
Gets the component container iterator for going through all the components in the container.

Specified by:
getComponentIterator in interface HasComponents
Returns:
the Iterator of the components inside the container.
See Also:
HasComponents.getComponentIterator()

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.
See Also:
VariableOwner.changeVariables(Object, Map)

getScrollLeft

public int getScrollLeft()
Description copied from interface: Scrollable
Gets scroll left offset.

Scrolling offset is the number of pixels this scrollable has been scrolled right.

Specified by:
getScrollLeft in interface Scrollable
Returns:
Horizontal scrolling position in pixels.

getScrollTop

public int getScrollTop()
Description copied from interface: Scrollable
Gets scroll top offset.

Scrolling offset is the number of pixels this scrollable has been scrolled down.

Specified by:
getScrollTop in interface Scrollable
Returns:
Vertical scrolling position in pixels.

setScrollLeft

public void setScrollLeft(int scrollLeft)
Description copied from interface: Scrollable
Sets scroll left offset.

Scrolling offset is the number of pixels this scrollable has been scrolled right.

Specified by:
setScrollLeft in interface Scrollable
Parameters:
scrollLeft - the xOffset.

setScrollTop

public void setScrollTop(int scrollTop)
Description copied from interface: Scrollable
Sets scroll top offset.

Scrolling offset is the number of pixels this scrollable has been scrolled down.

The scrolling position is limited by the current height of the content area. If the position is below the height, it is scrolled to the bottom. However, if the same response also adds height to the content area, scrolling to bottom only scrolls to the bottom of the previous content area.

Specified by:
setScrollTop in interface Scrollable
Parameters:
scrollTop - the yOffset.

replaceComponent

public void replaceComponent(Component oldComponent,
                             Component newComponent)
Description copied from interface: ComponentContainer
Replaces the component in the container with another one without changing position.

This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.

Specified by:
replaceComponent in interface ComponentContainer
Parameters:
oldComponent - the old component that will be replaced.
newComponent - the new component to be replaced.

componentAttachedToContainer

public void componentAttachedToContainer(ComponentContainer.ComponentAttachEvent event)
A new component is attached to container.

Specified by:
componentAttachedToContainer in interface ComponentContainer.ComponentAttachListener
Parameters:
event - the component attach event.
See Also:
ComponentContainer.ComponentAttachListener.componentAttachedToContainer(com.vaadin.ui.ComponentContainer.ComponentAttachEvent)

componentDetachedFromContainer

public void componentDetachedFromContainer(ComponentContainer.ComponentDetachEvent event)
A component has been detached from container.

Specified by:
componentDetachedFromContainer in interface ComponentContainer.ComponentDetachListener
Parameters:
event - the component detach event.
See Also:
ComponentContainer.ComponentDetachListener.componentDetachedFromContainer(com.vaadin.ui.ComponentContainer.ComponentDetachEvent)

removeAllComponents

public void removeAllComponents()
Removes all components from this container.

Specified by:
removeAllComponents in interface ComponentContainer
Overrides:
removeAllComponents in class AbstractComponentContainer
See Also:
ComponentContainer.removeAllComponents()

getActionManager

protected ActionManager getActionManager()
Description copied from class: AbstractComponent
Gets the ActionManager used to manage the ShortcutListeners added to this Field.

Overrides:
getActionManager in class AbstractComponent
Returns:
the ActionManager in use

addAction

public <T extends Action & Action.Listener> void addAction(T action)
Specified by:
addAction in interface Action.Notifier

removeAction

public <T extends Action & Action.Listener> void removeAction(T action)
Specified by:
removeAction in interface Action.Notifier

addActionHandler

public void addActionHandler(Action.Handler actionHandler)
Description copied from interface: Action.Container
Registers a new action handler for this container

Specified by:
addActionHandler in interface Action.Container
Parameters:
actionHandler - the new handler to be added.

removeActionHandler

public void removeActionHandler(Action.Handler actionHandler)
Description copied from interface: Action.Container
Removes a previously registered action handler for the contents of this container.

Specified by:
removeActionHandler in interface Action.Container
Parameters:
actionHandler - the handler to be removed.

removeAllActionHandlers

public void removeAllActionHandlers()
Removes all action handlers


addListener

public void addListener(MouseEvents.ClickListener listener)
Add a click listener to the Panel. The listener is called whenever the user clicks inside the Panel. Also when the click targets a component inside the Panel, provided the targeted component does not prevent the click event from propagating. Use #removeListener(ClickListener) to remove the listener.

Parameters:
listener - The listener to add

removeListener

public void removeListener(MouseEvents.ClickListener listener)
Remove a click listener from the Panel. The listener should earlier have been added using #addListener(ClickListener).

Parameters:
listener - The listener to remove

getTabIndex

public int getTabIndex()
Gets the tabulator index of the Focusable component.

Specified by:
getTabIndex in interface Component.Focusable
Returns:
tab index set for the Focusable component
See Also:
Component.Focusable.setTabIndex(int)

setTabIndex

public void setTabIndex(int tabIndex)
Sets the tabulator index of the Focusable component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.
 Form loginBox = new Form();
 loginBox.setCaption("Login");
 layout.addComponent(loginBox);
 
 // Create the first field which will be focused
 TextField username = new TextField("User name");
 loginBox.addField("username", username);
 
 // Set focus to the user name
 username.focus();
 
 TextField password = new TextField("Password");
 loginBox.addField("password", password);
 
 Button login = new Button("Login");
 loginBox.getFooter().addComponent(login);
 
 // An additional component which natural focus order would
 // be after the button.
 CheckBox remember = new CheckBox("Remember me");
 loginBox.getFooter().addComponent(remember);
 
 username.setTabIndex(1);
 password.setTabIndex(2);
 remember.setTabIndex(3); // Different than natural place
 login.setTabIndex(4);
 

After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.

If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.

A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.

Specified by:
setTabIndex in interface Component.Focusable
Parameters:
tabIndex - the tab order of this component. Indexes usually start from 1. Zero means that default tab order should be used. A negative value means that the field should not be included in the tabbing sequence.
See Also:
Component.Focusable.getTabIndex()

focus

public void focus()
Moves keyboard focus to the component. Component.Focusable.focus()

Specified by:
focus in interface Component.Focusable
Overrides:
focus in class AbstractComponent
See Also:
FieldEvents, FieldEvents.FocusEvent, FieldEvents.FocusListener, FieldEvents.BlurEvent, FieldEvents.BlurListener

getComponentCount

public int getComponentCount()
Description copied from interface: ComponentContainer
Gets the number of children this ComponentContainer has. This must be symmetric with what HasComponents.getComponentIterator() returns.

Specified by:
getComponentCount in interface ComponentContainer
Returns:
The number of child components this container has.

getState

public PanelState getState()
Description copied from class: AbstractComponent
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().

Specified by:
getState in interface Connector
Specified by:
getState in interface Component
Overrides:
getState in class AbstractComponent
Returns:
updated component shared state


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