Package com.vaadin.ui

Class Panel

    • 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).
      • Panel

        public Panel​(String caption,
                     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 Detail

      • setCaption

        public void setCaption​(String caption)
        Sets the caption of the panel. Note that the caption is interpreted as HTML 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)
      • paintContent

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

        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 LegacyComponent
        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:
        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.
      • 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
      • addClickListener

        public void 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. Use removeListener(ClickListener) to remove the listener.
        Parameters:
        listener - The listener to add
      • removeClickListener

        public void removeClickListener​(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
      • 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()
      • getState

        protected 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().
        Overrides:
        getState in class AbstractComponent
        Returns:
        updated component shared state
      • readDesign

        public void readDesign​(org.jsoup.nodes.Element design,
                               DesignContext designContext)
        Description copied from interface: Component
        Reads 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:
        readDesign in interface Component
        Overrides:
        readDesign in class AbstractSingleComponentContainer
        Parameters:
        design - The element to obtain the state from
        designContext - The DesignContext instance used for parsing the design
      • writeDesign

        public void writeDesign​(org.jsoup.nodes.Element design,
                                DesignContext designContext)
        Description copied from interface: Component
        Writes 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:
        writeDesign in interface Component
        Overrides:
        writeDesign in class AbstractSingleComponentContainer
        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