Interface Component.Focusable
-
- All Superinterfaces:
ClientConnector
,Component
,Connector
,Serializable
,Sizeable
- All Known Subinterfaces:
Field<T>
- All Known Implementing Classes:
AbstractField
,AbstractFocusable
,AbstractSelect
,AbstractTextField
,Accordion
,Button
,CheckBox
,ColorPickerPopup
,ComboBox
,CustomField
,DateField
,Form
,Grid
,InlineDateField
,LegacyWindow
,ListSelect
,MenuBar
,NativeButton
,NativeSelect
,OptionGroup
,Panel
,PasswordField
,PopupDateField
,ProgressBar
,ProgressIndicator
,RichTextArea
,Select
,Slider
,Table
,TabSheet
,TextArea
,TextField
,Tree
,TreeTable
,TwinColSelect
,UI
,Upload
,Window
- Enclosing interface:
- Component
public static interface Component.Focusable extends Component
A sub-interface implemented by components that can obtain input focus. This includes allField
components as well as some other components, such asUpload
.Focus can be set with
focus()
. This interface does not provide an accessor that would allow finding out the currently focused component; focus information can be acquired for some (but not all)Field
components through theFieldEvents.FocusListener
andFieldEvents.BlurListener
interfaces.- See Also:
FieldEvents
-
-
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.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
focus()
Sets the focus to this component.int
getTabIndex()
Gets the tabulator index of theFocusable
component.void
setTabIndex(int tabIndex)
Sets the tabulator index of theFocusable
component.-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, readDesign, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
-
-
-
-
Method Detail
-
focus
void focus()
Sets the focus to this component.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);
Notice that this interface does not provide an accessor that would allow finding out the currently focused component. Focus information can be acquired for some (but not all)
Field
components through theFieldEvents.FocusListener
andFieldEvents.BlurListener
interfaces.
-
getTabIndex
int getTabIndex()
Gets the tabulator index of theFocusable
component.- Returns:
- tab index set for the
Focusable
component - See Also:
setTabIndex(int)
-
setTabIndex
void setTabIndex(int tabIndex)
Sets the tabulator index of theFocusable
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.
- 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:
getTabIndex()
-
-