Class Panel
-
- All Implemented Interfaces:
Action.Container,Action.Notifier,ConnectorEventListener,ContextClickEvent.ContextClickNotifier,MethodEventSource,SerializableEventListener,ClientConnector,Scrollable,Sizeable,VariableOwner,Connector,Component,Component.Focusable,HasComponents,HasComponents.ComponentAttachDetachNotifier,LegacyComponent,SingleComponentContainer,Serializable,Iterable<Component>,EventListener
- Direct Known Subclasses:
Window
public class Panel extends AbstractSingleComponentContainer implements Scrollable, Action.Notifier, Component.Focusable, LegacyComponent
Panel - a simple single component container.- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
Fields Modifier and Type Field Description protected ActionManageractionManagerKeeps track of the Actions added to this component, and manages the painting and handling as well.-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
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
Constructors Constructor Description Panel()Creates a new empty panel.Panel(Component content)Creates a new empty panel which contains the given content.Panel(String caption)Creates a new empty panel with caption.Panel(String caption, Component content)Creates a new empty panel with the given caption and content.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T extends Action & Action.Listener>
voidaddAction(T action)voidaddActionHandler(Action.Handler actionHandler)Registers a new action handler for this container.RegistrationaddClickListener(MouseEvents.ClickListener listener)Add a click listener to the Panel.voidchangeVariables(Object source, Map<String,Object> variables)Called when one or more variables handled by the implementing class are changed.voidfocus()Moves keyboard focus to the component.protected ActionManagergetActionManager()Gets theActionManagerused to manage theShortcutListeners added to this component.protected Collection<String>getCustomAttributes()Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods.intgetScrollLeft()Gets scroll left offset.intgetScrollTop()Gets scroll top offset.protected PanelStategetState()Returns the shared state bean with information to be sent from the server to the client.protected PanelStategetState(boolean markAsDirty)Returns the shared state for this connector.intgetTabIndex()Gets the tabulator index of theFocusablecomponent.voidpaintContent(PaintTarget target)Paints the Paintable into a UIDL stream.voidreadDesign(org.jsoup.nodes.Element design, DesignContext designContext)Reads the component state from the given design.<T extends Action & Action.Listener>
voidremoveAction(T action)voidremoveActionHandler(Action.Handler actionHandler)Removes a previously registered action handler for the contents of this container.voidremoveAllActionHandlers()Removes all action handlers.voidremoveClickListener(MouseEvents.ClickListener listener)Deprecated.As of 8.0, replaced byRegistration.remove()in the registration object returned fromaddClickListener(ClickListener).voidsetCaption(String caption)Sets the caption of the component.voidsetScrollLeft(int scrollLeft)Sets scroll left offset.voidsetScrollTop(int scrollTop)Sets scroll top offset.voidsetTabIndex(int tabIndex)Sets the tabulator index of theFocusablecomponent.voidwriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractSingleComponentContainer
addComponentAttachListener, addComponentDetachListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentCount, getContent, iterator, readDesignChildren, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setContent, setHeight, setWidth
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, 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, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled
-
-
-
-
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.
-
Panel
public Panel(Component content)
Creates a new empty panel which contains the given content.- Parameters:
content- the content for the panel.
-
Panel
public Panel(String caption)
Creates a new empty panel with caption.- Parameters:
caption- the caption used in the panel (HTML).
-
-
Method Detail
-
setCaption
public void setCaption(String caption)
Description copied from interface:ComponentSets the caption of the component.A caption is an explanatory textual label accompanying a user interface component, usually shown above, left of, or inside the component. Icon (see
setIcon()is closely related to caption and is usually displayed horizontally before or after it, depending on the component and the containing layout.The caption can usually also be given as the first parameter to a constructor, though some components do not support it.
RichTextArea area = new RichTextArea(); area.setCaption("You can edit stuff here"); area.setValue("<h1>Helpful Heading</h1>" + "<p>All this is for you to edit.</p>");The contents of a caption are automatically quoted, so no raw HTML can be rendered in a caption. The validity of the used character encoding, usually UTF-8, is not checked.
The caption of a component is, by default, managed and displayed by the layout component or component container in which the component is placed. For example, the
VerticalLayoutcomponent shows the captions left-aligned above the contained components, while theFormLayoutcomponent shows the captions on the left side of the vertically laid components, with the captions and their associated components left-aligned in their own columns. TheCustomComponentdoes not manage the caption of its composition root, so if the root component has a caption, it will not be rendered. Some components, such asButtonandPanel, manage the caption themselves and display it inside the component.- Specified by:
setCaptionin interfaceComponent- Overrides:
setCaptionin classAbstractComponent- Parameters:
caption- the new caption for the component. If the caption isnull, no caption is shown and it does not normally take any space
-
paintContent
public void paintContent(PaintTarget target) throws PaintException
Description copied from interface:LegacyComponentPaints 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:
paintContentin interfaceLegacyComponent- Parameters:
target- the target UIDL stream where the component should paint itself to.- Throws:
PaintException- if the paint operation failed.
-
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:
changeVariablesin interfaceVariableOwner- 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:ScrollableGets scroll left offset.Scrolling offset is the number of pixels this scrollable has been scrolled right.
- Specified by:
getScrollLeftin interfaceScrollable- Returns:
- Horizontal scrolling position in pixels.
-
getScrollTop
public int getScrollTop()
Description copied from interface:ScrollableGets scroll top offset.Scrolling offset is the number of pixels this scrollable has been scrolled down.
- Specified by:
getScrollTopin interfaceScrollable- Returns:
- Vertical scrolling position in pixels.
-
setScrollLeft
public void setScrollLeft(int scrollLeft)
Description copied from interface:ScrollableSets scroll left offset.Scrolling offset is the number of pixels this scrollable has been scrolled right.
- Specified by:
setScrollLeftin interfaceScrollable- Parameters:
scrollLeft- the xOffset.
-
setScrollTop
public void setScrollTop(int scrollTop)
Description copied from interface:ScrollableSets 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:
setScrollTopin interfaceScrollable- Parameters:
scrollTop- the yOffset.
-
getActionManager
protected ActionManager getActionManager()
Description copied from class:AbstractComponentGets theActionManagerused to manage theShortcutListeners added to this component.- Overrides:
getActionManagerin classAbstractComponent- Returns:
- the ActionManager in use
-
addAction
public <T extends Action & Action.Listener> void addAction(T action)
- Specified by:
addActionin interfaceAction.Notifier
-
removeAction
public <T extends Action & Action.Listener> void removeAction(T action)
- Specified by:
removeActionin interfaceAction.Notifier
-
addActionHandler
public void addActionHandler(Action.Handler actionHandler)
Description copied from interface:Action.ContainerRegisters a new action handler for this container.- Specified by:
addActionHandlerin interfaceAction.Container- Parameters:
actionHandler- the new handler to be added.
-
removeActionHandler
public void removeActionHandler(Action.Handler actionHandler)
Description copied from interface:Action.ContainerRemoves a previously registered action handler for the contents of this container.- Specified by:
removeActionHandlerin interfaceAction.Container- Parameters:
actionHandler- the handler to be removed.
-
removeAllActionHandlers
public void removeAllActionHandlers()
Removes all action handlers.
-
addClickListener
public Registration addClickListener(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.- Parameters:
listener- The listener to add, not null- Returns:
- a registration object for removing the listener
- Since:
- 8.0
- See Also:
Registration
-
removeClickListener
@Deprecated public void removeClickListener(MouseEvents.ClickListener listener)
Deprecated.As of 8.0, replaced byRegistration.remove()in the registration object returned fromaddClickListener(ClickListener).Remove a click listener from the Panel. The listener should earlier have been added usingaddClickListener(ClickListener).- Parameters:
listener- The listener to remove
-
getTabIndex
public int getTabIndex()
Gets the tabulator index of theFocusablecomponent.- Specified by:
getTabIndexin interfaceComponent.Focusable- Returns:
- tab index set for the
Focusablecomponent - See Also:
Component.Focusable.setTabIndex(int)
-
setTabIndex
public void setTabIndex(int tabIndex)
Sets the tabulator index of theFocusablecomponent. 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:
setTabIndexin 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()
-
focus
public void focus()
Moves keyboard focus to the component.Component.Focusable.focus()- Specified by:
focusin interfaceComponent.Focusable- Overrides:
focusin classAbstractComponent- See Also:
FieldEvents,FieldEvents.FocusEvent,FieldEvents.FocusListener,FieldEvents.BlurEvent,FieldEvents.BlurListener
-
getState
protected PanelState getState()
Description copied from class:AbstractComponentReturns 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:
getStatein classAbstractSingleComponentContainer- Returns:
- updated component shared state
-
getState
protected PanelState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classAbstractSingleComponentContainer- 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()
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentReads the component state from the given design.The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
- Specified by:
readDesignin interfaceComponent- Overrides:
readDesignin classAbstractSingleComponentContainer- Parameters:
design- The element to obtain the state fromdesignContext- The DesignContext instance used for parsing the design
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:AbstractComponentReturns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributesin classAbstractComponent- Returns:
- the collection of attributes that are not handled by the basic implementation
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentWrites the component state to the given design.The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
- Specified by:
writeDesignin interfaceComponent- Overrides:
writeDesignin classAbstractSingleComponentContainer- Parameters:
design- The element to write the component state to. Any previous attributes or child nodes are not cleared.designContext- The DesignContext instance used for writing the design
-
-