|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vaadin.terminal.AbstractClientConnector com.vaadin.ui.AbstractComponent com.vaadin.ui.Button
public class Button
A generic button component.
Nested Class Summary | |
---|---|
class |
Button.ClickEvent
Click event. |
static interface |
Button.ClickListener
Interface for listening for a Button.ClickEvent fired by a
Component . |
static class |
Button.ClickShortcut
A ShortcutListener specifically made to define a keyboard
shortcut that invokes a click on the given button. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
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 | |
---|---|
protected Button.ClickShortcut |
clickShortcut
|
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 |
Constructor Summary | |
---|---|
Button()
Creates a new push button. |
|
Button(String caption)
Creates a new push button with the given caption. |
|
Button(String caption,
Button.ClickListener listener)
Creates a new push button with a click listener. |
Method Summary | |
---|---|
void |
addListener(Button.ClickListener listener)
Adds the button click listener. |
void |
addListener(FieldEvents.BlurListener listener)
Adds a BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
void |
addListener(FieldEvents.FocusListener listener)
Adds a FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
void |
click()
Simulates a button click, notifying all server-side listeners. |
protected void |
fireClick()
Fires a click event to all listeners without any event details. |
protected void |
fireClick(MouseEventDetails details)
Fires a click event to all listeners. |
void |
focus()
Sets the focus for this component if the component is Focusable . |
ButtonState |
getState()
Returns the shared state bean with information to be sent from the server to the client. |
int |
getTabIndex()
Gets the tabulator index of the Focusable component. |
boolean |
isDisableOnClick()
Determines if a button is automatically disabled when clicked. |
boolean |
isHtmlContentAllowed()
Return HTML rendering setting |
void |
removeClickShortcut()
Removes the keyboard shortcut previously set with setClickShortcut(int, int...) . |
void |
removeListener(Button.ClickListener listener)
Removes the button click listener. |
void |
removeListener(FieldEvents.BlurListener listener)
Removes a BlurListener from the Component. |
void |
removeListener(FieldEvents.FocusListener listener)
Removes a FocusListener from the Component. |
void |
setClickShortcut(int keyCode,
int... modifiers)
Makes it possible to invoke a click on this button by pressing the given ShortcutAction.KeyCode and (optional) ShortcutAction.ModifierKey s.The shortcut is global (bound to the containing Window). |
void |
setDisableOnClick(boolean disableOnClick)
Determines if a button is automatically disabled when clicked. |
void |
setHtmlContentAllowed(boolean htmlContentAllowed)
Set whether the caption text is rendered as HTML or not. |
void |
setTabIndex(int tabIndex)
Sets the tabulator index of the Focusable component. |
Methods inherited from class com.vaadin.terminal.AbstractClientConnector |
---|
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, attach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, 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 |
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier |
---|
addShortcutListener, removeShortcutListener |
Field Detail |
---|
protected Button.ClickShortcut clickShortcut
Constructor Detail |
---|
public Button()
public Button(String caption)
caption
- the Button caption.public Button(String caption, Button.ClickListener listener)
caption
- the Button caption.listener
- the Button click listener.Method Detail |
---|
public void addListener(Button.ClickListener listener)
listener
- the Listener to be added.public void removeListener(Button.ClickListener listener)
listener
- the Listener to be removed.public void click()
protected void fireClick()
fireClick(MouseEventDetails)
instead of
this method.
protected void fireClick(MouseEventDetails details)
details
- MouseEventDetails from which keyboard modifiers and other
information about the mouse click can be obtained. If the
button was clicked by a keyboard event, some of the fields may
be empty/undefined.public void addListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
to the Component which gets fired
when a Field
loses keyboard focus.
addListener
in interface FieldEvents.BlurNotifier
FieldEvents.BlurListener
public void removeListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
from the Component.
removeListener
in interface FieldEvents.BlurNotifier
FieldEvents.BlurListener
public void addListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
to the Component which gets fired
when a Field
receives keyboard focus.
addListener
in interface FieldEvents.FocusNotifier
FieldEvents.FocusListener
public void removeListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
from the Component.
removeListener
in interface FieldEvents.FocusNotifier
FieldEvents.FocusListener
public void setClickShortcut(int keyCode, int... modifiers)
ShortcutAction.KeyCode
and (optional) ShortcutAction.ModifierKey
s.
keyCode
- the keycode for invoking the shortcutmodifiers
- the (optional) modifiers for invoking the shortcut, null for
nonepublic void removeClickShortcut()
setClickShortcut(int, int...)
.
public boolean isDisableOnClick()
setDisableOnClick(boolean)
for details.
public void setDisableOnClick(boolean disableOnClick)
disableOnClick
- true to disable button when it is clicked, false otherwisepublic int getTabIndex()
Component.Focusable
Focusable
component.
getTabIndex
in interface Component.Focusable
Focusable
componentComponent.Focusable.setTabIndex(int)
public void setTabIndex(int tabIndex)
Component.Focusable
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.
setTabIndex
in interface Component.Focusable
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.Component.Focusable.getTabIndex()
public void focus()
AbstractComponent
Focusable
.
focus
in interface Component.Focusable
focus
in class AbstractComponent
FieldEvents
,
FieldEvents.FocusEvent
,
FieldEvents.FocusListener
,
FieldEvents.BlurEvent
,
FieldEvents.BlurListener
public ButtonState getState()
AbstractComponent
getState
in interface Connector
getState
in interface Component
getState
in class AbstractComponent
public void setHtmlContentAllowed(boolean htmlContentAllowed)
htmlContentAllowed
- true
if caption is rendered as HTML,
false
otherwisepublic boolean isHtmlContentAllowed()
true
if the caption text is to be rendered as HTML,
false
otherwise
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |