com.itmill.toolkit.ui
Class Button

java.lang.Object
  extended by com.itmill.toolkit.terminal.Identifiable
      extended by com.itmill.toolkit.ui.AbstractComponent
          extended by com.itmill.toolkit.ui.AbstractField
              extended by com.itmill.toolkit.ui.Button
All Implemented Interfaces:
Buffered, BufferedValidatable, Property, Property.Editor, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.Container, MethodEventSource, Paintable, VariableOwner, Component, Component.Focusable, Field, EventListener

public class Button
extends AbstractField
implements Action.Container

A generic button component.

Since:
3.0
Version:
4.1.4
Author:
IT Mill Ltd.

Nested Class Summary
 class Button.ClickEvent
          Click event.
static interface Button.ClickListener
          Button click listener
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractField
AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Constructor Summary
Button()
          Creates a new push button.
Button(String caption)
          Creates a new push button.
Button(String caption, boolean initialState)
          Creates a new switch button with initial value.
Button(String caption, Button.ClickListener listener)
          Creates a new push button with click listener.
Button(String caption, Object target, String methodName)
          Creates a new push button with a method listening button clicks.
Button(String caption, Property dataSource)
          Creates a new switch button that is connected to a boolean property.
 
Method Summary
 void addActionHandler(Action.Handler actionHandler)
          Adds an action handler.
 void addListener(Button.ClickListener listener)
          Adds the button click listener.
 void changeVariables(Object source, Map variables)
          Invoked when the value of a variable has changed.
protected  void fireClick()
          Emits the options change event.
 String getTag()
          Gets component UIDL tag.
 Class getType()
          The type of the button as a property.
 boolean isSwitchMode()
          Checks if it is switchMode.
 void paintContent(PaintTarget target)
          Paints the content of this component.
 void removeActionHandler(Action.Handler actionHandler)
          Removes an action handler.
 void removeListener(Button.ClickListener listener)
          Removes the button click listener.
 void setImmediate(boolean immediate)
          Sets immediate mode.
 void setSwitchMode(boolean switchMode)
          Sets the switchMode.
 
Methods inherited from class com.itmill.toolkit.ui.AbstractField
addListener, addListener, addValidator, attach, commit, constructField, discard, finalize, fireReadOnlyStatusChange, fireValueChange, focus, getErrorMessage, getFocusableId, getPropertyDataSource, getTabIndex, getValidators, getValue, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isWriteThrough, removeListener, removeListener, removeValidator, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setTabIndex, setValue, setWriteThrough, toString, validate, valueChange
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, childRequestedRepaint, dependsOn, detach, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDescription, setEnabled, setIcon, setLocale, setParent, setStyle, setVisible
 
Methods inherited from class com.itmill.toolkit.terminal.Identifiable
getDebugId, getUIID, setDebugId, setUIID
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.itmill.toolkit.ui.Field
getDescription, setCaption, setDescription
 
Methods inherited from interface com.itmill.toolkit.ui.Component
addListener, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isVisible, removeListener, setEnabled, setParent, setStyle, setVisible
 
Methods inherited from interface com.itmill.toolkit.terminal.Paintable
addListener, paint, removeListener, requestRepaint, requestRepaintRequests
 
Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner
dependsOn, getDirectDependencies, isImmediate, removeDirectDependency
 

Constructor Detail

Button

public Button()
Creates a new push button. The value of the push button is allways false and they are immediate by default.


Button

public Button(String caption)
Creates a new push button. The value of the push button is allways false and they are immediate by default.

Parameters:
caption - the Button caption.

Button

public Button(String caption,
              Button.ClickListener listener)
Creates a new push button with click listener.

Parameters:
caption - the Button caption.
listener - the Button click listener.

Button

public Button(String caption,
              Object target,
              String methodName)
Creates a new push button with a method listening button clicks. The method must have either no parameters, or only one parameter of Button.ClickEvent type.

Parameters:
caption - the Button caption.
target - the Object having the method for listening button clicks.
methodName - the name of the method in target object, that receives button click events.

Button

public Button(String caption,
              boolean initialState)
Creates a new switch button with initial value.

Parameters:
state - the Initial state of the switch-button.
initialState -

Button

public Button(String caption,
              Property dataSource)
Creates a new switch button that is connected to a boolean property.

Parameters:
state - the Initial state of the switch-button.
dataSource -
Method Detail

getTag

public String getTag()
Gets component UIDL tag.

Specified by:
getTag in class AbstractComponent
Returns:
the Component UIDL tag as string.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

Overrides:
paintContent in class AbstractField
Parameters:
event - the PaintEvent.
Throws:
IOException - if the writing failed due to input/output error.
PaintException - if the paint operation failed.

changeVariables

public void changeVariables(Object source,
                            Map variables)
Invoked when the value of a variable has changed. Button listeners are notified if the button is clicked.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractComponent
Parameters:
source -
variables -

isSwitchMode

public boolean isSwitchMode()
Checks if it is switchMode.

Returns:
true if it is in Switch Mode, otherwise false.

setSwitchMode

public void setSwitchMode(boolean switchMode)
Sets the switchMode.

Parameters:
switchMode - The switchMode to set.

setImmediate

public void setImmediate(boolean immediate)
Sets immediate mode. Push buttons can not be set in non-immediate mode.

Overrides:
setImmediate in class AbstractComponent
Parameters:
immediate - the boolean value specifying if the component should be in the immediate mode after the call.
See Also:
AbstractComponent.setImmediate(boolean)

getType

public Class getType()
The type of the button as a property.

Specified by:
getType in interface Property
Specified by:
getType in class AbstractField
Returns:
type of the Property
See Also:
Property.getType()

addListener

public void addListener(Button.ClickListener listener)
Adds the button click listener.

Parameters:
listener - the Listener to be added.

removeListener

public void removeListener(Button.ClickListener listener)
Removes the button click listener.

Parameters:
listener - the Listener to be removed.

fireClick

protected void fireClick()
Emits the options change event.


addActionHandler

public void addActionHandler(Action.Handler actionHandler)
Adds an action handler.

Specified by:
addActionHandler in interface Action.Container
Parameters:
actionHandler - the new handler to be added.
See Also:
Action.Container.addActionHandler(Action.Handler)

removeActionHandler

public void removeActionHandler(Action.Handler actionHandler)
Removes an action handler.

Specified by:
removeActionHandler in interface Action.Container
Parameters:
actionHandler - the handler to be removed.
See Also:
Action.Container.removeActionHandler(Action.Handler)


Copyright © 2000-2008 IT Mill Ltd. All Rights Reserved.