Skip to main content
Version: 7.9

Button

Component Palette Icon

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. While you could configure your script on a mousePressed or mouseClicked event handlers, it is better to use the actionPerformed event as buttons can be activated by tabbing over to them and hitting the space key, or 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 smoother.boolean.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 enter 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 filled.boolean.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 on this component.Font.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 image.int.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-mnemonic'.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 styles.Dataset.stylesAppearance
TextText of this component.String.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 image.int.verticalTextPositionLayout
VisibleIf disabled, the component will be hidden.boolean.visibleCommon

Scripting

Scripting Functions

.doClick()

  • Description
        Virtually "clicks" the button, meaning that its actionPerformed event handler will run.
  • Parameters
        Nothing
  • Return
        Nothing
  • Scope
        Client

Extension Functions

This component does not have extension functions associated with it.

Event Handlers

Event handlers allow you to run a script based off specific triggers. See the full list of available event handlers on the Component Events page

Customizers

Styled Button Examples

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

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