com.vaadin.ui.
Class Panel
java.lang.Object
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractComponentContainer
com.vaadin.ui.Panel
All Implemented Interfaces:
Action.Container, Action.Notifier, MethodEventSource, Paintable, Scrollable, Sizeable, VariableOwner, Component, Component.Focusable, ComponentContainer, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Serializable, EventListener
Direct Known Subclasses:
- extends AbstractComponentContainer
- implements Scrollable, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Action.Notifier, Component.Focusable
public class Panel
Panel - a simple single component container.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
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.ui.Component |
---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable |
---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
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. |
static String |
STYLE_LIGHT
Deprecated. this style is no longer part of the core framework and this component, even though most built-in themes implement this style. Use the constant specified in the theme class file that you're using, if it provides one, e.g. Reindeer.PANEL_LIGHT or Runo.PANEL_LIGHT . |
Fields inherited from interface com.vaadin.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNIT_SYMBOLS, 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 | ||
---|---|---|
|
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 |
attach()
Notifies the component that it is connected to an application. |
|
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 |
detach()
Notifies the component that it is detached from the application. |
|
void |
focus()
Moves keyboard focus to the component. |
|
protected ActionManager |
getActionManager()
|
|
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. |
|
Layout |
getLayout()
Deprecated. A Panel can now contain a ComponentContainer which is not necessarily a Layout. Use getContent() instead. |
|
int |
getScrollLeft()
Gets scroll left offset. |
|
int |
getScrollOffsetX()
Deprecated. use getScrollLeft() instead |
|
int |
getScrollOffsetY()
Deprecated. use getScrollTop() instead |
|
int |
getScrollTop()
Gets scroll top offset. |
|
int |
getTabIndex()
Gets the tabulator index of the Focusable component. |
|
boolean |
isScrollable()
Is programmatic scrolling enabled. |
|
void |
paintContent(PaintTarget target)
Paints any needed component-specific things to the given UIDL stream. |
|
|
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 |
requestRepaintAll()
Causes a repaint of this component, and all components below it. |
|
void |
setCaption(String caption)
Sets the caption of the panel. |
|
void |
setContent(ComponentContainer newContent)
Set the content of the Panel. |
|
void |
setLayout(Layout newLayout)
Deprecated. A Panel can now contain a ComponentContainer which is not necessarily a Layout. Use setContent(ComponentContainer) instead. |
|
void |
setScrollable(boolean isScrollingEnabled)
Sets the panel as programmatically scrollable. |
|
void |
setScrollLeft(int pixelsScrolled)
Sets the horizontal scroll position. |
|
void |
setScrollOffsetX(int pixels)
Deprecated. use setScrollLeft() method instead |
|
void |
setScrollOffsetY(int pixels)
Deprecated. use setScrollTop() method instead |
|
void |
setScrollTop(int pixelsScrolledDown)
Sets the vertical scroll position. |
|
void |
setTabIndex(int tabIndex)
Sets the tabulator index of the Focusable component. |
Methods inherited from class com.vaadin.ui.AbstractComponentContainer |
---|
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeListener, removeListener, setEnabled, setHeight, setWidth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible |
Methods inherited from interface com.vaadin.terminal.Paintable |
---|
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId |
Methods inherited from interface com.vaadin.terminal.VariableOwner |
---|
isImmediate |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Field Detail |
---|
STYLE_LIGHT
@Deprecated
public static final String STYLE_LIGHT
- See Also:
- Constant Field Values
Deprecated. this style is no longer part of the core framework and this
component, even though most built-in themes implement this
style. Use the constant specified in the theme class file
that you're using, if it provides one, e.g.
Reindeer.PANEL_LIGHT
or Runo.PANEL_LIGHT
.
Removes extra decorations from the Panel.
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)
- Parameters:
content
- the content for the panel.
Creates a new empty panel which contains the given content. The content cannot be null.
Panel
public Panel(String caption)
- Parameters:
caption
- the caption used in the panel (HTML/XHTML).
Creates a new empty panel with caption. Default layout is used.
Panel
public Panel(String caption,
ComponentContainer content)
- Parameters:
caption
- the caption of the panel (HTML/XHTML).content
- the content used in the panel.
Creates a new empty panel with the given caption and content.
Method Detail |
---|
setCaption
public void setCaption(String caption)
- Specified by:
setCaption
in interfaceComponent
- Overrides:
setCaption
in classAbstractComponent
- Parameters:
caption
- the new captionString
for the component.- See Also:
AbstractComponent.setCaption(String)
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.
getLayout
@Deprecated
public Layout getLayout()
- Returns:
- the Current layout of the panel.
Deprecated. A Panel can now contain a ComponentContainer which is not
necessarily a Layout. Use getContent()
instead.
Gets the current layout of the panel.
setLayout
@Deprecated
public void setLayout(Layout newLayout)
- Parameters:
newLayout
- the New layout of the panel.
Deprecated. A Panel can now contain a ComponentContainer which is not
necessarily a Layout. Use
setContent(ComponentContainer)
instead.
Sets the layout of the panel. If given layout is null, a VerticalLayout with margins set is used as a default. Components from old layout are not moved to new layout by default (changed in 5.2.2). Use function in Layout interface manually.
getContent
public ComponentContainer getContent()
- Returns:
Returns the content of the Panel.
setContent
public void setContent(ComponentContainer newContent)
- Parameters:
content
- The new content
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.
paintContent
public void paintContent(PaintTarget target)
throws PaintException
- Overrides:
paintContent
in classAbstractComponent
- Parameters:
target
- the target UIDL stream where the component should paint itself to- Throws:
PaintException
- if the paint operation failed.
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The
more general AbstractComponent.paint(PaintTarget)
method handles all general
attributes common to all components, and it calls this method to paint
any component-specific attributes to the UIDL stream.
requestRepaintAll
public void requestRepaintAll()
- Specified by:
requestRepaintAll
in interfaceComponentContainer
- Overrides:
requestRepaintAll
in classAbstractComponentContainer
Description copied from interface: ComponentContainer
Causes a repaint of this component, and all components below it. This should only be used in special cases, e.g when the state of a descendant depends on the state of a ancestor.
addComponent
public void addComponent(Component c)
- Specified by:
addComponent
in interfaceComponentContainer
- Overrides:
addComponent
in classAbstractComponentContainer
- Parameters:
c
- the component to be added.- See Also:
AbstractComponentContainer.addComponent(com.vaadin.ui.Component)
Adds the component into this container.
removeComponent
public void removeComponent(Component c)
- Specified by:
removeComponent
in interfaceComponentContainer
- Overrides:
removeComponent
in classAbstractComponentContainer
- Parameters:
c
- The component to be removed.- See Also:
AbstractComponentContainer.removeComponent(com.vaadin.ui.Component)
Removes the component from this container.
getComponentIterator
public Iterator<Component> getComponentIterator()
- Specified by:
getComponentIterator
in interfaceComponentContainer
- Returns:
- the Iterator of the components inside the container.
- See Also:
ComponentContainer.getComponentIterator()
Gets the component container iterator for going through all the components in the container.
changeVariables
public void changeVariables(Object source,
Map<String,Object> variables)
- Specified by:
changeVariables
in interfaceVariableOwner
- Overrides:
changeVariables
in classAbstractComponent
- 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)
Called when one or more variables handled by the implementing class are changed.
getScrollLeft
public int getScrollLeft()
- Specified by:
getScrollLeft
in interfaceScrollable
- Returns:
- Horizontal scrolling position in pixels.
Description copied from interface: Scrollable
Gets scroll left offset.
Scrolling offset is the number of pixels this scrollable has been scrolled right.
getScrollOffsetX
@Deprecated
public int getScrollOffsetX()
Deprecated. use getScrollLeft()
instead
getScrollTop
public int getScrollTop()
- Specified by:
getScrollTop
in interfaceScrollable
- Returns:
- Vertical scrolling position in pixels.
Description copied from interface: Scrollable
Gets scroll top offset.
Scrolling offset is the number of pixels this scrollable has been scrolled down.
getScrollOffsetY
@Deprecated
public int getScrollOffsetY()
Deprecated. use getScrollTop()
instead
isScrollable
public boolean isScrollable()
- Specified by:
isScrollable
in interfaceScrollable
- Returns:
true
if the scrolling is enabled, otherwisefalse
.
Description copied from interface: Scrollable
Is programmatic scrolling enabled.
Whether programmatic scrolling with Scrollable.setScrollLeft(int)
and
Scrollable.setScrollTop(int)
is enabled.
setScrollable
public void setScrollable(boolean isScrollingEnabled)
- Specified by:
setScrollable
in interfaceScrollable
- Parameters:
isScrollingEnabled
- true if the scrolling is allowed.- See Also:
Scrollable.setScrollable(boolean)
Sets the panel as programmatically scrollable.
Panel is by default not scrollable programmatically with
setScrollLeft(int)
and setScrollTop(int)
, so if you use
those methods, you need to enable scrolling with this method. Components
that extend Panel may have a different default for the programmatic
scrollability.
setScrollLeft
public void setScrollLeft(int pixelsScrolled)
- Specified by:
setScrollLeft
in interfaceScrollable
- Parameters:
pixelsScrolled
- the xOffset.- See Also:
Scrollable.setScrollLeft(int)
,setScrollable(boolean)
Sets the horizontal scroll position.
Setting the horizontal scroll position with this method requires that
programmatic scrolling of the component has been enabled. For Panel it is
disabled by default, so you have to call setScrollable(boolean)
.
Components extending Panel may have a different default for programmatic
scrollability.
setScrollOffsetX
@Deprecated
public void setScrollOffsetX(int pixels)
Deprecated. use setScrollLeft() method instead
setScrollTop
public void setScrollTop(int pixelsScrolledDown)
- Specified by:
setScrollTop
in interfaceScrollable
- Parameters:
pixelsScrolledDown
- the yOffset.- See Also:
Scrollable.setScrollTop(int)
,setScrollable(boolean)
Sets the vertical scroll position.
Setting the vertical scroll position with this method requires that
programmatic scrolling of the component has been enabled. For Panel it is
disabled by default, so you have to call setScrollable(boolean)
.
Components extending Panel may have a different default for programmatic
scrollability.
setScrollOffsetY
@Deprecated
public void setScrollOffsetY(int pixels)
Deprecated. use setScrollTop() method instead
replaceComponent
public void replaceComponent(Component oldComponent,
Component newComponent)
- Specified by:
replaceComponent
in interfaceComponentContainer
- Parameters:
oldComponent
- the old component that will be replaced.newComponent
- the new component to be replaced.
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.
componentAttachedToContainer
public void componentAttachedToContainer(ComponentContainer.ComponentAttachEvent event)
- Specified by:
componentAttachedToContainer
in interfaceComponentContainer.ComponentAttachListener
- Parameters:
event
- the component attach event.- See Also:
ComponentContainer.ComponentAttachListener.componentAttachedToContainer(com.vaadin.ui.ComponentContainer.ComponentAttachEvent)
A new component is attached to container.
componentDetachedFromContainer
public void componentDetachedFromContainer(ComponentContainer.ComponentDetachEvent event)
- Specified by:
componentDetachedFromContainer
in interfaceComponentContainer.ComponentDetachListener
- Parameters:
event
- the component detach event.- See Also:
ComponentContainer.ComponentDetachListener.componentDetachedFromContainer(com.vaadin.ui.ComponentContainer.ComponentDetachEvent)
A component has been detached from container.
attach
public void attach()
- Specified by:
attach
in interfaceComponent
- Overrides:
attach
in classAbstractComponentContainer
- See Also:
Component.attach()
Notifies the component that it is connected to an application.
detach
public void detach()
- Specified by:
detach
in interfaceComponent
- Overrides:
detach
in classAbstractComponentContainer
- See Also:
Component.detach()
Notifies the component that it is detached from the application.
removeAllComponents
public void removeAllComponents()
- Specified by:
removeAllComponents
in interfaceComponentContainer
- Overrides:
removeAllComponents
in classAbstractComponentContainer
Removes all components from this container.
getActionManager
protected ActionManager getActionManager()
addAction
public <T extends Action & Action.Listener> void addAction(T action)
- Specified by:
addAction
in interfaceAction.Notifier
removeAction
public <T extends Action & Action.Listener> void removeAction(T action)
- Specified by:
removeAction
in interfaceAction.Notifier
addActionHandler
public void addActionHandler(Action.Handler actionHandler)
- Specified by:
addActionHandler
in interfaceAction.Container
- Parameters:
actionHandler
- the new handler to be added.
Description copied from interface: Action.Container
Registers a new action handler for this container
removeActionHandler
public void removeActionHandler(Action.Handler actionHandler)
- Specified by:
removeActionHandler
in interfaceAction.Container
- Parameters:
actionHandler
- the handler to be removed.
Description copied from interface: Action.Container
Removes a previously registered action handler for the contents of this container.
removeAllActionHandlers
public void removeAllActionHandlers()
Removes all action handlers
addListener
public void addListener(MouseEvents.ClickListener listener)
- Parameters:
listener
- The listener to add
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.
removeListener
public void removeListener(MouseEvents.ClickListener listener)
- Parameters:
listener
- The listener to remove
Remove a click listener from the Panel. The listener should earlier have
been added using #addListener(ClickListener)
.
getTabIndex
public int getTabIndex()
- Specified by:
getTabIndex
in interfaceComponent.Focusable
- Returns:
- tab index set for the
Focusable
component - See Also:
Component.Focusable.setTabIndex(int)
Gets the tabulator index of the Focusable
component.
setTabIndex
public void setTabIndex(int tabIndex)
- Specified by:
setTabIndex
in interfaceComponent.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()
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.
focus
public void focus()
- Specified by:
focus
in interfaceComponent.Focusable
- Overrides:
focus
in classAbstractComponent
Moves keyboard focus to the component. Component.Focusable.focus()