Package com.ardor3d.extension.ui
Class UIButton
- All Implemented Interfaces:
UIKeyHandler
,Textable
,Hintable
,Savable
- Direct Known Subclasses:
UICheckBox
,UIMenuItem
,UIRadioButton
,UITab
A state based component that can be interacted with via the mouse to trigger actions.
-
Field Summary
Modifier and TypeFieldDescriptionprotected LabelState
Default state to use for the button.protected LabelState
State to use when the mouse button is disabled while currently selected.protected LabelState
State to use when the mouse button is disabled.protected LabelState
State to use when the mouse is hovering over this button while currently selected.protected LabelState
State to use when the mouse is hovering over this button.protected LabelState
State to use when the mouse button is pressed and held down over this button.protected LabelState
State to use when the mouse button is currently selected.Fields inherited from class com.ardor3d.extension.ui.AbstractLabelUIComponent
_styled
Fields inherited from class com.ardor3d.extension.ui.UIComponent
_tooltipPopTime, _tooltipText, DEFAULT_FOREGROUND_COLOR
Fields inherited from class com.ardor3d.scenegraph.Spatial
_controllers, _delegateMap, _dirtyMark, _frustumIntersects, _listener, _localTransform, _name, _parent, _queueDistance, _renderStateList, _sceneHints, _userData, _worldBound, _worldTransform, ON_DIRTY_ATTACHED, ON_DIRTY_BOUNDING, ON_DIRTY_RENDERSTATE, ON_DIRTY_TRANSFORM, ON_DIRTY_TRANSFORM_ONLY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionListener
(ActionListener listener) Add the specified listener to this button's list of listeners notified when pressed.void
doClick()
Manually click the button.void
Notifies all of this button's registered listeners that this button was pressed.getGroup()
boolean
boolean
boolean
boolean
boolean
mousePressed
(MouseButton button, InputState state) always mark consumed.boolean
mouseReleased
(MouseButton button, InputState state) always mark consumed.boolean
removeActionListener
(ActionListener listener) Remove the given listener from the notification list.void
Removes all of this button's listeners from notification list.void
setActionCommand
(String actionCommand) void
setButtonIcon
(SubTex icon) Sets the icon on this button and all contained states.void
setButtonText
(String text) Sets the text on this button and all contained states.void
setButtonText
(String text, boolean isStyled) Sets the text on this button and all contained states.void
setEnabled
(boolean enabled) void
setGroup
(ButtonGroup group) void
setSelectable
(boolean selectable) void
setSelected
(boolean selected) If selectable, set this button's state to either selected (true) or default (false) - or disabled versions of each if currently disabled.Methods inherited from class com.ardor3d.extension.ui.AbstractLabelUIComponent
drawComponent, fireStyleChanged, getAlignment, getGap, getIcon, getIconDimensions, getText, getTextObject, isStyledText, setAlignment, setGap, setIcon, setIconDimensions, setStyledText, setText, updateChildren, updateIconDimensionsFromIcon, updateMinimumSizeFromContents
Methods inherited from class com.ardor3d.extension.ui.StateBasedUIComponent
gainedFocus, getCurrentState, keyHeld, keyPressed, keyReleased, lostFocus, mouseDeparted, mouseEntered, mouseMoved, mouseWheel, refreshState, setForegroundColor, switchState
Methods inherited from class com.ardor3d.extension.ui.UIComponent
addFontStyle, applySkin, attachedToHud, cancelTooltipTimer, centerOn, centerOn, clearFontStyle, clearMaximumContentSize, clearMinimumContentSize, compact, detachedFromHud, draw, fireComponentDirty, fitComponentIn, getBackdrop, getBorder, getCombinedOpacity, getContentHeight, getContentWidth, getCurrentOpacity, getDefaultFontFamily, getDefaultFontSize, getDefaultFontStyles, getFontStyles, getForegroundColor, getHud, getHudX, getHudY, getKeyFocusTarget, getLayoutData, getLocalComponentHeight, getLocalComponentWidth, getLocalFontStyles, getLocalForegroundColor, getLocalOpacity, getLocalX, getLocalY, getMargin, getMaximumContentHeight, getMaximumContentWidth, getMaximumLocalComponentHeight, getMaximumLocalComponentWidth, getMinimumContentHeight, getMinimumContentWidth, getMinimumLocalComponentHeight, getMinimumLocalComponentWidth, getPadding, getRelativeComponentBounds, getRelativeMaxComponentBounds, getRelativeMinComponentBounds, getTooltipPopTime, getTooltipText, getTopLevelComponent, getTotalBottom, getTotalLeft, getTotalRight, getTotalTop, getUIComponent, hasVirginContentArea, insideMargin, isAttachedToHUD, isConsumeKeyEvents, isConsumeMouseEvents, isEnabled, isUseTransparency, isVisible, layout, mouseClicked, pack, postdrawComponent, predrawComponent, requestFocus, setBackdrop, setBorder, setConsumeKeyEvents, setConsumeMouseEvents, setContentHeight, setContentSize, setContentWidth, setDefaultFontFamily, setDefaultFontSize, setDefaultFontStyles, setFontStyles, setForegroundColor, setHudX, setHudXY, setHudY, setKeyFocusTarget, setLayoutData, setLayoutMinimumContentSize, setLocalComponentHeight, setLocalComponentSize, setLocalComponentWidth, setLocalX, setLocalXY, setLocalY, setMargin, setMaximumContentHeight, setMaximumContentSize, setMaximumContentWidth, setMinimumContentHeight, setMinimumContentSize, setMinimumContentWidth, setOpacity, setPadding, setTooltipPopTime, setTooltipText, setUseTransparency, setVirginContentArea, setVisible, updateWorldTransform, updateWorldTransform, validateContentSize
Methods inherited from class com.ardor3d.scenegraph.Node
acceptVisitor, attachChild, attachChildAt, detachAllChildren, detachChild, detachChildAt, detachChildNamed, getChild, getChild, getChildIndex, getChildren, getClassTag, getNumberOfChildren, hasChild, makeCopy, makeInstanced, propagateDirtyDown, read, sortLights, swapChildren, updateWorldBound, updateWorldRenderStates, write
Methods inherited from class com.ardor3d.scenegraph.Spatial
addController, addTranslation, addTranslation, applyWorldRenderStates, clearControllers, clearDirty, clearDirty, clearRenderState, getController, getControllerCount, getControllers, getCurrentRenderDelegate, getLastFrustumIntersection, getListener, getLocalLastFrustumIntersection, getLocalRenderState, getLocalRenderStates, getName, getParent, getParentHintable, getRenderDelegate, getRotation, getScale, getSceneHints, getTransform, getTranslation, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, isDirty, localToWorld, markDirty, markDirty, onDraw, propagateBoundToRoot, propagateDirtyUp, propagateStatesFromRoot, propageEventUp, removeController, removeController, removeFromParent, setLastFrustumIntersection, setListener, setName, setParent, setRenderDelegate, setRenderState, setRotation, setRotation, setScale, setScale, setScale, setTransform, setTranslation, setTranslation, setUserData, setWorldRotation, setWorldRotation, setWorldScale, setWorldScale, setWorldScale, setWorldTransform, setWorldTranslation, setWorldTranslation, toString, updateControllers, updateGeometricState, updateGeometricState, updateWorldRenderStates, worldToLocal
-
Field Details
-
_defaultState
Default state to use for the button. -
_disabledState
State to use when the mouse button is disabled. -
_pressedState
State to use when the mouse button is pressed and held down over this button. -
_mouseOverState
State to use when the mouse is hovering over this button. -
_selectedState
State to use when the mouse button is currently selected. -
_mouseOverSelectedState
State to use when the mouse is hovering over this button while currently selected. -
_disabledSelectedState
State to use when the mouse button is disabled while currently selected.
-
-
Constructor Details
-
UIButton
public UIButton()Construct a new, blank button -
UIButton
Construct a new button with the given text.- Parameters:
text
- the text
-
UIButton
Construct a new button with the given text and icon.- Parameters:
text
- the texticon
- the icon
-
-
Method Details
-
isPressed
public boolean isPressed()- Returns:
- true if the pressed state is our current state.
-
isMouseOver
public boolean isMouseOver()- Returns:
- true if the mouse over state is our current state.
-
addActionListener
Add the specified listener to this button's list of listeners notified when pressed.- Parameters:
listener
- the listener
-
removeActionListener
Remove the given listener from the notification list.- Parameters:
listener
- the listener- Returns:
true
if the listener has been effectively removed
-
removeAllListeners
public void removeAllListeners()Removes all of this button's listeners from notification list. -
fireActionEvent
public void fireActionEvent()Notifies all of this button's registered listeners that this button was pressed. -
getMouseOverState
-
getMouseOverSelectedState
-
getPressedState
-
getSelectedState
-
getDisabledSelectedState
-
mousePressed
always mark consumed.- Overrides:
mousePressed
in classStateBasedUIComponent
- Parameters:
button
- the button that was pressedstate
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
mouseReleased
always mark consumed.- Overrides:
mouseReleased
in classStateBasedUIComponent
- Parameters:
button
- the button that was releasedstate
- the current tracked state of the input system.- Returns:
- true if we want to consider the event "consumed" by the UI system.
-
isSelected
public boolean isSelected()- Returns:
- true if button is selectable and is selected.
-
setSelected
public void setSelected(boolean selected) If selectable, set this button's state to either selected (true) or default (false) - or disabled versions of each if currently disabled.- Parameters:
selected
- the selection value to set
-
setSelectable
public void setSelectable(boolean selectable) - Parameters:
selectable
- true if this button should be selectable
-
isSelectable
public boolean isSelectable()- Returns:
- true if button is selectable
-
setGroup
- Parameters:
group
- the group this button should belong to. Removes the button from any group it currently belongs to.
-
getGroup
- Returns:
- the button group this button belongs to or null if it belongs to none.
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabled
in classStateBasedUIComponent
- Parameters:
enabled
- if true, sets the defaultState to active, otherwise sets the disabledState or disabledSelectedState to active.
-
getDefaultState
- Specified by:
getDefaultState
in classStateBasedUIComponent
- Returns:
- the state that represents the default appearance and behavior for this component.
-
getDisabledState
- Specified by:
getDisabledState
in classStateBasedUIComponent
- Returns:
- the state that represents the disabled appearance and behavior for this component.
-
setButtonText
Sets the text on this button and all contained states.- Parameters:
text
- the new text
-
setButtonText
Sets the text on this button and all contained states.- Parameters:
text
- the new textisStyled
- if true, the text may contain style markup.
-
setButtonIcon
Sets the icon on this button and all contained states.- Parameters:
icon
- the new icon
-
getActionCommand
-
setActionCommand
-
doClick
public void doClick()Manually click the button. -
getStates
- Specified by:
getStates
in classStateBasedUIComponent
- Returns:
- an ImmutableSet of possible states for this component.
-