Class Panel

All Implemented Interfaces:
Action.Container, Action.Notifier, ClientConnector, Sizeable, Focusable, HasComponents, HasComponents.ComponentAttachDetachNotifier, SingleComponentContainer, com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.shared.HasTooltip, Serializable, Iterable<com.vaadin.flow.component.Component>

@CssImport("./panel.css") @Tag("div") public class Panel extends AbstractSingleComponentContainer implements Focusable, Action.Notifier
Legacy version of Panel - a simple single component container.
Author:
Vaadin Ltd.
See Also:
  • Constructor Details

    • Panel

      public Panel()
      Creates a new empty panel.
    • Panel

      public Panel(com.vaadin.flow.component.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).
    • Panel

      public Panel(String caption, com.vaadin.flow.component.Component content)
      Creates a new empty panel with the given caption and content.
      Parameters:
      caption - the caption of the panel (HTML).
      content - the content used in the panel.
  • Method Details

    • beforeClientResponse

      public void beforeClientResponse(boolean initial)
      Description copied from interface: ClientConnector
      Called before the response is written to client side. Gives the legacy connector an opportunity to set computed/dynamic state values.

      This is implemented for the legacy components to keep consistent behavior and e.g. legaze size calculations working.

      NOTE: the parameter initial is false when the component is attached again to a new UI when PreserveOnRefresh is used.

      Specified by:
      beforeClientResponse in interface ClientConnector
      Overrides:
      beforeClientResponse in class AbstractComponent
      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.
    • addClickListener

      public com.vaadin.flow.shared.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
      See Also:
      • Registration
    • setCaption

      public void setCaption(String caption)
      Sets 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.

       Panel panel = new Panel();
       panel.setCaption("Panel caption");
       

      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 is displayed inside the component.

      Overrides:
      setCaption in class AbstractComponent
      Parameters:
      caption - the new caption for the component. If the caption is null, no caption is shown, and it does not normally take any space
    • getCaption

      public String getCaption()
      Gets the caption of the component.

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

      Overrides:
      getCaption in class AbstractComponent
      Returns:
      the caption of the component or null if the caption is not set.
      See Also:
    • setCaptionAsHtml

      public void setCaptionAsHtml(boolean captionAsHtml)
      Sets whether the caption is rendered as HTML.

      If set to true, the captions are rendered in the browser as HTML and the developer is responsible for ensuring no harmful HTML is used. If set to false, the caption is rendered in the browser as plain text.

      Note: Unlike the Label component in Vaadin 7/8, the script tag is removed when the caption is rendered as html The default is false, i.e. to render that caption as plain text.

      Overrides:
      setCaptionAsHtml in class AbstractComponent
      Parameters:
      captionAsHtml - true if the captions are rendered as HTML, false if rendered as plain text
    • isCaptionAsHtml

      public boolean isCaptionAsHtml()
      Checks whether captions are rendered as HTML

      The default is false, i.e. to render that caption as plain text.

      Overrides:
      isCaptionAsHtml in class AbstractComponent
      Returns:
      true if the captions are rendered as HTML, false if rendered as plain text
    • setIcon

      public void setIcon(com.vaadin.flow.component.icon.Icon icon)
      Sets the icon of the component.

      An icon is an explanatory graphical label accompanying a user interface component, usually shown above, left of, or inside the component. Icon is closely related to caption (see setCaption()) and is displayed horizontally before..

       // Component with an icon from a custom theme
       Panel panel = new Panel("Name");
       panel.setIcon(VaadinIcon.COPY.create());
       layout.addComponent(name);
       

      An icon will be rendered inside an HTML element that has the v-icon CSS style class. The containing layout may enclose an icon and a caption inside elements related to the caption, such as v-caption .

      Parameters:
      icon - the icon of the component. If null, no icon is shown, and it does not normally take any space.
      See Also:
    • getIcon

      public Resource getIcon()

      Non-op method.

      In order to get the icon set with setIcon(Icon), use getIconAsIcon()

      Overrides:
      getIcon in class AbstractComponent
      Returns:
      fake resource
      See Also:
    • getIconAsIcon

      public com.vaadin.flow.component.icon.Icon getIconAsIcon()
      Gets the icon resource of the component.

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

      Returns:
      the icon component or null if the component has no icon
      See Also:
    • getScrollLeft

      public int getScrollLeft()
      Gets scroll left offset.

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

      Returns:
      Horizontal scrolling position in pixels.
    • setScrollLeft

      public void setScrollLeft(int scrollLeft)
      Sets scroll left offset.

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

      Parameters:
      scrollLeft - the xOffset.
    • getScrollTop

      public int getScrollTop()
      Gets scroll top offset.

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

      Returns:
      Vertical scrolling position in pixels.
    • setScrollTop

      public void setScrollTop(int scrollTop)
      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.

      Parameters:
      scrollTop - the yOffset.
    • focus

      public void focus()
      Description copied from class: AbstractComponent
      Sets the focus for this component if the component is Focusable. NOTE: the focus is not set until the component is attached.
      Specified by:
      focus in interface Focusable
      Overrides:
      focus in class AbstractComponent
    • getTabIndex

      public int getTabIndex()
      Description copied from interface: Focusable
      Gets the tabulator index of the Focusable component.
      Specified by:
      getTabIndex in interface Focusable
      Returns:
      tab index set for the Focusable component
      See Also:
    • setTabIndex

      public void setTabIndex(int tabIndex)
      Description copied from interface: Focusable
      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.

      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 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:
    • addAction

      @Deprecated public <T extends Action & Action.Listener> void addAction(T action)
      Deprecated.
      Description copied from interface: Action.Notifier
      Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
      Specified by:
      addAction in interface Action.Notifier
      Type Parameters:
      T - type
      Parameters:
      action - action
    • removeAction

      @Deprecated public <T extends Action & Action.Listener> void removeAction(T action)
      Deprecated.
      Description copied from interface: Action.Notifier
      Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
      Specified by:
      removeAction in interface Action.Notifier
      Type Parameters:
      T - type
      Parameters:
      action - action
    • addActionHandler

      @Deprecated public void addActionHandler(Action.Handler actionHandler)
      Deprecated.
      Description copied from interface: Action.Container
      Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
      Specified by:
      addActionHandler in interface Action.Container
      Parameters:
      actionHandler - the new handler to be added.
    • removeActionHandler

      @Deprecated public void removeActionHandler(Action.Handler actionHandler)
      Deprecated.
      Description copied from interface: Action.Container
      Not supported. See Classic Component Pack documentation in https://vaadin.com/docs/latest/flow/upgrading/legacy-component-pack for mitigation options.
      Specified by:
      removeActionHandler in interface Action.Container
      Parameters:
      actionHandler - the handler to be removed.