Package com.vaadin.ui

Class CustomField<T>

    • Constructor Detail

      • CustomField

        public CustomField()
        Constructs a new custom field.

        The component is implemented by wrapping the methods of the composition root component given as parameter. The composition root must be set before the component can be used.

    • Method Detail

      • getContent

        protected Component getContent()
        Returns the content (UI) of the custom component.
        Returns:
        Component
      • initContent

        protected abstract Component initContent()
        Create the content component or layout for the field. Subclasses of CustomField should implement this method. Note that this method is called when the CustomField is attached to a layout or when getContent() is called explicitly for the first time. It is only called once for a CustomField.
        Returns:
        Component representing the UI of the CustomField
      • setHeight

        public void setHeight​(float height,
                              Sizeable.Unit unit)
        Description copied from interface: Sizeable
        Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).
        Specified by:
        setHeight in interface Sizeable
        Overrides:
        setHeight in class AbstractComponent
        Parameters:
        height - the height of the object.
        unit - the unit used for the width.
      • setWidth

        public void setWidth​(float width,
                             Sizeable.Unit unit)
        Description copied from interface: Sizeable
        Sets the width of the object. Negative number implies unspecified size (terminal is free to set the size).
        Specified by:
        setWidth in interface Sizeable
        Overrides:
        setWidth in class AbstractComponent
        Parameters:
        width - the width of the object.
        unit - the unit used for the width.
      • iterator

        public Iterator<Component> iterator()
        Description copied from interface: HasComponents
        Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.
        Specified by:
        iterator in interface HasComponents
        Specified by:
        iterator in interface Iterable<T>
        Returns:
        the component iterator.
      • setFocusDelegate

        public void setFocusDelegate​(Component.Focusable focusDelegate)
        Sets the component to which all methods from the Component.Focusable interface should be delegated.

        Set this to a wrapped field to include that field in the tabbing order, to make it receive focus when focus() is called and to make it be correctly focused when used as a Grid editor component.

        By default, Component.Focusable events are handled by the super class and ultimately ignored.

        Parameters:
        focusDelegate - the focusable component to which focus events are redirected
      • setTabIndex

        public void setTabIndex​(int tabIndex)
        Description copied from interface: Component.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.
         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
        Overrides:
        setTabIndex in class AbstractField<T>
        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()