com.vaadin.ui
Interface Component.Focusable

All Superinterfaces:
ClientConnector, Component, Connector, RpcTarget, Serializable, Sizeable
All Known Subinterfaces:
Field<T>
All Known Implementing Classes:
AbstractField, AbstractSelect, AbstractTextField, Accordion, Button, CheckBox, ComboBox, CustomField, DateField, Form, InlineDateField, ListSelect, NativeButton, NativeSelect, OptionGroup, Panel, PasswordField, PopupDateField, ProgressIndicator, RichTextArea, Select, Slider, Table, TabSheet, TextArea, TextField, Tree, TreeTable, TwinColSelect, 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 all Field components as well as some other components, such as Upload.

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 the FieldEvents.FocusListener and FieldEvents.BlurListener interfaces.

See Also:
FieldEvents

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
Field Summary
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Method Summary
 void focus()
          Sets the focus to this component.
 int getTabIndex()
          Gets the tabulator index of the Focusable component.
 void setTabIndex(int tabIndex)
          Sets the tabulator index of the Focusable component.
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getState, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, setVisible, updateState
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
detach, getExtensions, getStateType, isConnectorEnabled, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 

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 the FieldEvents.FocusListener and FieldEvents.BlurListener interfaces.

See Also:
FieldEvents, FieldEvents.FocusEvent, FieldEvents.FocusListener, FieldEvents.BlurEvent, FieldEvents.BlurListener

getTabIndex

int getTabIndex()
Gets the tabulator index of the Focusable component.

Returns:
tab index set for the Focusable component
See Also:
setTabIndex(int)

setTabIndex

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.

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()


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.