Package org.apache.pivot.wtk
Class Button
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- org.apache.pivot.wtk.Button
-
- All Implemented Interfaces:
ConstrainedVisual
,Visual
- Direct Known Subclasses:
CalendarButton
,Checkbox
,ColorChooserButton
,LinkButton
,ListButton
,Menu.Item
,MenuBar.Item
,MenuButton
,PushButton
,RadioButton
,TerraAccordionSkin.PanelHeader
,TerraCalendarSkin.DateButton
,TerraPanoramaSkin.ScrollButton
,TerraTabPaneSkin.TabButton
public abstract class Button extends Component
Abstract base class for button components.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Button.ButtonDataBindMapping
Translates between a button's buttonData and context data during data binding.static interface
Button.DataRenderer
Renderer
interface to customize the appearance of data in a Button.static interface
Button.SelectedBindMapping
Translates between selection state and context data during data binding.static class
Button.State
Enumeration representing a button's selection state.static interface
Button.StateBindMapping
Translates between button state and context data during data binding.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears any bound values in the component.Action
getAction()
Returns the action associated with this button.ListenerList<ButtonBindingListener>
getButtonBindingListeners()
java.lang.Object
getButtonData()
Button.ButtonDataBindMapping
getButtonDataBindMapping()
BindType
getButtonDataBindType()
java.lang.String
getButtonDataKey()
ButtonGroup
getButtonGroup()
Returns the button's button group.ListenerList<ButtonListener>
getButtonListeners()
ListenerList<ButtonPressListener>
getButtonPressListeners()
ListenerList<ButtonStateListener>
getButtonStateListeners()
Button.DataRenderer
getDataRenderer()
int
getQueuedActionDelay()
Button.SelectedBindMapping
getSelectedBindMapping()
BindType
getSelectedBindType()
java.lang.String
getSelectedKey()
Button.State
getState()
Button.StateBindMapping
getStateBindMapping()
BindType
getStateBindType()
java.lang.String
getStateKey()
boolean
isQueuedAction()
boolean
isSelected()
boolean
isToggleButton()
boolean
isTriState()
void
load(java.lang.Object context)
Copies bound values from the bind context to the component.void
press()
"Presses" the button.void
setAction(java.lang.String actionID)
Sets this button's action.void
setAction(Action action)
Sets this button's action.void
setButtonData(java.lang.Object buttonData)
void
setButtonDataBindMapping(Button.ButtonDataBindMapping buttonDataBindMapping)
Set the bind mapping used for this button's data.void
setButtonDataBindType(BindType buttonDataBindType)
void
setButtonDataKey(java.lang.String buttonDataKey)
Set the binding key to use for this button's data.void
setButtonGroup(ButtonGroup buttonGroup)
Sets the button's button group.void
setDataRenderer(Button.DataRenderer dataRenderer)
void
setEnabled(boolean enabled)
Sets the component's enabled state.void
setQueuedAction(boolean flag)
Sets the "queued action" flag so that actions invoked on button press are queued to theApplicationContext
callback queue to be run "later" instead of being invoked now.void
setQueuedActionDelay(int delay)
Set the delay to be used whensetQueuedAction(boolean)
is set totrue
.void
setSelected(boolean selected)
Sets the button's selected state.void
setSelectedBindMapping(Button.SelectedBindMapping selectedBindMapping)
void
setSelectedBindType(BindType selectedBindType)
void
setSelectedKey(java.lang.String selectedKey)
void
setState(Button.State state)
Sets the button's tri-state selection state.void
setStateBindMapping(Button.StateBindMapping stateBindMapping)
void
setStateBindType(BindType stateBindType)
void
setStateKey(java.lang.String stateKey)
void
setToggleButton(boolean toggleButton)
Sets the button's toggle state.void
setTriState(boolean triState)
Sets the button's tri-state state.void
store(java.lang.Object context)
Copies bound values from the component to the bind context.-
Methods inherited from class org.apache.pivot.wtk.Component
checkSkin, clearFocus, contains, copyStyle, copyStyle, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, layout, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, offsetToScreen, paint, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setAutomationID, setCursor, setDragSource, setDropTarget, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setParent, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setVisible, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
-
-
-
-
Method Detail
-
getButtonData
public java.lang.Object getButtonData()
-
setButtonData
public void setButtonData(java.lang.Object buttonData)
-
getDataRenderer
public Button.DataRenderer getDataRenderer()
-
setDataRenderer
public void setDataRenderer(Button.DataRenderer dataRenderer)
-
getAction
public Action getAction()
Returns the action associated with this button.- Returns:
- The button's action, or
null
if no action is defined.
-
setAction
public void setAction(Action action)
Sets this button's action.- Parameters:
action
- The action to be triggered when this button is pressed, ornull
for no action.
-
setAction
public void setAction(java.lang.String actionID)
Sets this button's action.- Parameters:
actionID
- The ID of the action to be triggered when this button is pressed.- Throws:
java.lang.IllegalArgumentException
- If an action with the given ID does not exist.
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from class:Component
Sets the component's enabled state. Enabled components respond to user input events; disabled components do not.- Overrides:
setEnabled
in classComponent
- Parameters:
enabled
-true
if the component is enabled;false
, otherwise.
-
press
public void press()
"Presses" the button. Performs any action associated with the button.
-
isSelected
public boolean isSelected()
- Returns:
- The button's selected state.
-
setSelected
public void setSelected(boolean selected)
Sets the button's selected state.- Parameters:
selected
- The new "selected" value.
-
getState
public Button.State getState()
- Returns:
- The button's selection state (for tri-state buttons).
-
setState
public void setState(Button.State state)
Sets the button's tri-state selection state.- Parameters:
state
- The new button selection state.
-
isToggleButton
public boolean isToggleButton()
- Returns:
- The button's toggle state.
-
setToggleButton
public void setToggleButton(boolean toggleButton)
Sets the button's toggle state.- Parameters:
toggleButton
- Whether or not this should be a toggle button.
-
isTriState
public boolean isTriState()
- Returns:
- The button's tri-state state.
-
setTriState
public void setTriState(boolean triState)
Sets the button's tri-state state.- Parameters:
triState
- Whether or not to make this a tri-state button.
-
isQueuedAction
public boolean isQueuedAction()
- Returns:
- Whether or not actions are executed immediately or are queued
for later on
press()
.
-
setQueuedAction
public void setQueuedAction(boolean flag)
Sets the "queued action" flag so that actions invoked on button press are queued to theApplicationContext
callback queue to be run "later" instead of being invoked now.- Parameters:
flag
- The new value of the queued action flag for this button.
-
getQueuedActionDelay
public int getQueuedActionDelay()
- Returns:
- The (millisecond) delay to use when queuing actions for later.
-
setQueuedActionDelay
public void setQueuedActionDelay(int delay)
Set the delay to be used whensetQueuedAction(boolean)
is set totrue
.Typically this delay would be a bit longer than the popup window fade transition (for instance), or similar timing.
- Parameters:
delay
- The delay value (in milliseconds) to use when queuing the action, or0
to use no delay.
-
getButtonGroup
public ButtonGroup getButtonGroup()
Returns the button's button group.- Returns:
- The group to which the button belongs, or
null
if the button does not belong to a group.
-
setButtonGroup
public void setButtonGroup(ButtonGroup buttonGroup)
Sets the button's button group.- Parameters:
buttonGroup
- The group to which the button will belong, ornull
if the button will not belong to a group.
-
getButtonDataKey
public java.lang.String getButtonDataKey()
- Returns:
- The binding key used for this button's data.
-
setButtonDataKey
public void setButtonDataKey(java.lang.String buttonDataKey)
Set the binding key to use for this button's data.- Parameters:
buttonDataKey
- The binding key for button data, which should be a field name or object "property" that supplies the button data.
-
getButtonDataBindType
public BindType getButtonDataBindType()
- Returns:
- The type of binding used for button data (that is "load", "store" or "both").
-
setButtonDataBindType
public void setButtonDataBindType(BindType buttonDataBindType)
-
getButtonDataBindMapping
public Button.ButtonDataBindMapping getButtonDataBindMapping()
- Returns:
- The bind mapping used for button data.
-
setButtonDataBindMapping
public void setButtonDataBindMapping(Button.ButtonDataBindMapping buttonDataBindMapping)
Set the bind mapping used for this button's data. This is a method that is used make a translation between the type of object needed for this button's data and the actual data supplied by the bound object.- Parameters:
buttonDataBindMapping
- The new mapping to use (can benull
to disable bind mapping).
-
getSelectedKey
public java.lang.String getSelectedKey()
-
setSelectedKey
public void setSelectedKey(java.lang.String selectedKey)
-
getSelectedBindType
public BindType getSelectedBindType()
-
setSelectedBindType
public void setSelectedBindType(BindType selectedBindType)
-
getSelectedBindMapping
public Button.SelectedBindMapping getSelectedBindMapping()
-
setSelectedBindMapping
public void setSelectedBindMapping(Button.SelectedBindMapping selectedBindMapping)
-
getStateKey
public java.lang.String getStateKey()
-
setStateKey
public void setStateKey(java.lang.String stateKey)
-
getStateBindType
public BindType getStateBindType()
-
setStateBindType
public void setStateBindType(BindType stateBindType)
-
getStateBindMapping
public Button.StateBindMapping getStateBindMapping()
-
setStateBindMapping
public void setStateBindMapping(Button.StateBindMapping stateBindMapping)
-
load
public void load(java.lang.Object context)
Description copied from class:Component
Copies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
store
public void store(java.lang.Object context)
Description copied from class:Component
Copies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.
-
clear
public void clear()
Description copied from class:Component
Clears any bound values in the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
getButtonListeners
public ListenerList<ButtonListener> getButtonListeners()
-
getButtonStateListeners
public ListenerList<ButtonStateListener> getButtonStateListeners()
-
getButtonPressListeners
public ListenerList<ButtonPressListener> getButtonPressListeners()
-
getButtonBindingListeners
public ListenerList<ButtonBindingListener> getButtonBindingListeners()
-
-