com.itmill.toolkit.ui
Class Button

java.lang.Object
  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, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, EventListener
Direct Known Subclasses:
CheckBox

public class Button
extends AbstractField

A generic button component.

Since:
3.0
Version:
5.3.0
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 class com.itmill.toolkit.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field
Field.ValueChangeEvent
 
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
 
Field Summary
static String STYLE_LINK
           
 
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 addListener(Button.ClickListener listener)
          Adds the button click listener.
 boolean booleanValue()
          Get the boolean value of the button state.
 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 removeListener(Button.ClickListener listener)
          Removes the button click listener.
 void setImmediate(boolean immediate)
          Sets immediate mode.
protected  void setInternalValue(Object newValue)
          Sets the internal field value.
 void setSwitchMode(boolean switchMode)
          Sets the switchMode.
 
Methods inherited from class com.itmill.toolkit.ui.AbstractField
addListener, addListener, addValidator, attach, commit, constructField, discard, fireReadOnlyStatusChange, fireValueChange, focus, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, getValue, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, removeListener, removeListener, removeValidator, setCurrentBufferedSourceException, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, setValue, setWriteThrough, toString, validate, valueChange
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, addStyleName, childRequestedRepaint, detach, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, isEnabled, isImmediate, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setHeight, setHeightUnits, setIcon, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setWidth, setWidth, setWidth, setWidthUnits, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.itmill.toolkit.ui.Field
getDescription, setCaption, setDescription
 

Field Detail

STYLE_LINK

public static final String STYLE_LINK
See Also:
Constant Field Values
Constructor Detail

Button

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


Button

public Button(String caption)
Creates a new push button. The value of the push button is false and it is 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. Using this method is discouraged because it cannot be checked during compilation. Use Button(String, com.itmill.toolkit.ui.Button.ClickListener) instead. 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 AbstractField
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.

booleanValue

public boolean booleanValue()
Get the boolean value of the button state.

Returns:
True iff the button is pressed down or checked.

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.


setInternalValue

protected void setInternalValue(Object newValue)
Description copied from class: AbstractField
Sets the internal field value. This is purely used by AbstractField to change the internal Field value. It does not trigger valuechange events. It can be overriden by the inheriting classes to update all dependent variables.

Overrides:
setInternalValue in class AbstractField
Parameters:
newValue - the new value to be set.


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