Skip to end of metadata
Go to start of metadata
General

Component Palette Icon:



Description

The Button component is a versatile component, often used for things like opening/closing windows, writing to tags, and triggering any sort of scripting logic. It can be used for showing status, as well. For example, if you have three buttons, Hand, Off, and Auto, not only can they set those modes, but their background color can display the current mode, although you'd be better off using the Multi-State Button for this. 

 To get buttons to do things, you add an event handler to the actionPerformed event. Many new users to the 1.0.0 module will configure an event handler for the mouseClicked event instead. While this will work, it is better to use the actionPerformed event. Why? Buttons can also be activated by tabbing over to them and hitting the space key, or they could be activated by pressing Alt and the button's mnemonic character. So, to make sure that your button works in all of these cases, configure your event handler on the actionPerformed event, not the mouseClicked event.

Properties


NameDescriptionProperty TypeScriptingCategory
AntialiasDraw with antialias on? Makes text smootherboolean.antialiasAppearance
Background 3D?Should this button have a 3d type background, or a flat color one?boolean.background3DAppearance
Background ColorThe background color of the button.Color.buttonBGAppearance
BorderThe border surrounding this component. NOTE that the border is unaffected by rotation.Border.borderCommon
Border Painted?Should the border of this button be displayed?boolean.borderPaintedAppearance
CursorThe mouse cursor to use when hovering over this component.int.cursorCodeCommon
Data QualityThe data quality code for any tag bindings on this component.int.dataQualityData
Default ButtonIf true, this button will be activated when the user presses <i>enter</i> on the window.boolean.defaultBtnBehavior
Disabled Image PathThe relative path of the image to be displayed when this component is not enabled.String.disabledPathAppearance
EnabledIf disabled, a component cannot be used.boolean.componentEnabledCommon
Fill Area?Controls whether or not this button's internal area is filledboolean.contentAreaFilledAppearance
FocusableIf a button is not focusable, you will not be able to interact with it with the keyboard. This means you can't "tab" over to it.boolean.focusableBehavior
FontFont of text of this componentFont.fontAppearance
Foreground ColorThe foreground color of the component.Color.foregroundAppearance
Horizontal AlignmentThe horizontal alignment of the button's contents (text and/or image)int.horizontalAlignmentLayout
Horizontal Text PositionThe horizontal position of the button's text relative to its imageint.horizontalTextPositionLayout
Icon-Text SpacingThe space (in pixels) between the icon (if any) and the text (if any)int.iconTextGapAppearance
Image PathThe relative path of the image.String.pathAppearance
MarginThe space between a button's text and its borders.Insets.marginLayout
MnemonicA single letter that will activate the button using 'ALT-<i>mnemonic</i>'.String.mnemonicCharBehavior
Mouseover TextThe text that is displayed in the tooltip which pops up on mouseover of this component.String.toolTipTextCommon
NameThe name of this component.String.nameCommon
OpaqueIs this button completely opaque? Most aren't, so this should usually be false.boolean.opaqueCommon
RolloverIf true, the button may indicate that the mouse is hovering over it.boolean.rolloverEnabledBehavior
StylesContains the component's stylesDataset.stylesAppearance
TextText of this componentString.textAppearance
Vertical AlignmentThe vertical alignment of the button's contents (text and/or image)int.verticalAlignmentLayout
Vertical Text PositionThe vertical position of the button's text relative to its imageint.verticalTextPositionLayout
VisibleIf disabled, the component will be hidden.boolean.visibleCommon

Scripting
Scripting Functions

This component does not have scripting functions associated with it.Remove the panel below if there are no scripting functions.

.doClick()
  • Description

Virtually "clicks" the button, meaning that its actionPerformed event handler will run.

  • Parameters

Nothing

  • Return

Nothing

  • Scope

Client

Event Handlers
 action

PropertyDescription
sourceThe component that fired this event

 actionPerformed

This event occurs when a component that can receive input, such as a text box, receives the input focus. This usually occurs when a user clicks on the component or tabs over to it.

 focus
 focusGained

This event occurs when a component that can receive input, such as a text box, receives the input focus. This usually occurs when a user clicks on the component or tabs over to it.

PropertyDescription
sourceThe component that fired this event
oppositeComponentThe other component involved in thie focus change. That is, the component that lost focus in order for this one to gain it, or vise versa.

 focusLost

This event occurs when a component that had the input focus lost it to another component.

PropertyDescription
sourceThe component that fired this event
oppositeComponentThe other component involved in thie focus change. That is, the component that lost focus in order for this one to gain it, or vise versa.

 key
 keyPressed

An integer that indicates whether the state was changed to "Selected" (on) or "Deselected" (off). Compare this to the event object's constants to determine what the new state is.

PropertyDescription
sourceThe component that fired this event
keyCodeThe key code for this event. Used with the keyPressed and keyReleased events.
keyCharThe character that was typed. Used with the keyTyped event.
keyLocationReturns the location of the key that originated this key event. Some keys occur more than once on a key board, e.g. Additionally, some keys occur on the numeric keypad. This provides a way of distinguishing such keys. See the KEY_LOCATION constants in the
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 keyReleased

Fires when a key is released and the source component has the input focus. Works for all characters, including non-printable ones, such as SHIFT and F3.

PropertyDescription
sourceThe component that fired this event
keyCodeThe key code for this event. Used with the keyPressed and keyReleased events.
keyCharThe character that was typed. Used with the keyTyped event.
keyLocationReturns the location of the key that originated this key event. Some keys occur more than once on a key board, e.g. Additionally, some keys occur on the numeric keypad. This provides a way of distinguishing such keys. See the KEY_LOCATION constants in the
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 keyTyped

Fires whenever a bindable property of the source component changes. This works for standard and custom (dynamic) properties.

PropertyDescription
sourceThe component that fired this event
keyCodeThe key code for this event. Used with the keyPressed and keyReleased events.
keyCharThe character that was typed. Used with the keyTyped event.
keyLocationReturns the location of the key that originated this key event. Some keys occur more than once on a key board, e.g. Additionally, some keys occur on the numeric keypad. This provides a way of distinguishing such keys. See the KEY_LOCATION constants in the
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mouse
 mouseClicked

This event signifies a mouse click on the source component. A mouse click the combination of a mouse press and a mouse release, both of which must have occurred over the source component. Note that this event fires after the pressed and released events have fired.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mouseEntered

This event fires when the mouse enters the space over the source component.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mouseExited

This event fires when the mouse leaves the space over the source component.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mousePressed

This event fires when a mouse button is pressed down on the source component.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mouseReleased

This event fires when a mouse button is released, if that mouse button's press happened over this component.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mouseMotion
 mouseDragged

Fires when the mouse moves over a component after a button has been pushed.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 mouseMoved

Fires when the mouse moves over a component, but no buttons are pushed.

PropertyDescription
sourceThe component that fired this event
buttonThe code for the button that coused this event to fire.
clickCountThe number of mouse clicks associated with this event.
xThe x-coordinate (with respect to the source component) of this mouse event.
yThe y-coordinate (with respect to the source component) of this mouse event.
popupTriggerReturns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDownTrue (1) if the Alt key was held down during this event, false (0) otherwise.
controlDownTrue (1) if the Control key was held down during this event, false (0) otherwise.
shiftDownTrue (1) if the Shift key was held down during this event, false (0) otherwise.

 propertyChange
 propertyChange

Fires whenever a bindable property of the source component changes. This works for standard and custom (dynamic) properties.

PropertyDescription
sourceThe component that fired this event
newValueThe new value that this property changed to.
oldValueThe value that this property was before it changed. Note that not all components include an accurate oldValue in their events.
propertyNameThe name of the property that changed. NOTE: remember to always filter out these events for the property that you are looking for! Components often have many properties that change.

Customizers

This component does not have any custom properties.

Examples
Styled Button

Property NameValue
BorderEtched
FontDialog, Bold, 18
TextPress Me!
Image PathBuiltin/icons/48/check2.png
Styled Button

Property NameValue
BorderNo Border
Fill Area?False
Border Painted?False
TextNone
Image PathBuiltin/icons/48/stop.png
  • No labels