Top  | Previous | Next

Button

A standard<br>
push button

A standard
push button

Buttons can<br>
have images

Buttons can
have images

Buttons can<br>
be only images

Buttons can
be only images

Buttons can<br>
display state

Buttons can
display state

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.

 

See also:

Typical Navigation Strategy

Event Types

Properties

Appearance

Font

Font of text of this component

Scripting name

font

Data type

Font

Foreground Color

The foreground color of the component.

Scripting name

foreground

Data type

Color

Background Color

The background color of the button.

Scripting name

buttonBG

Data type

Color

Background 3D?

Should this button have a 3d type background, or a flat color one?

Scripting name

background3D

Data type

boolean

Flags

expert

Fill Area?

Controls whether or not this button's internal area is filled

Scripting name

contentAreaFilled

Data type

boolean

Flags

expert

Border Painted?

Should the border of this button be displayed?

Scripting name

borderPainted

Data type

boolean

Flags

expert

Text

Text of this component

Scripting name

text

Data type

String

Flags

bindable

Image Path

The relative path of the image.

Scripting name

path

Data type

String

Flags

bindable

Disabled Image Path

The relative path of the image to be displayed when this component is not enabled.

Scripting name

disabledPath

Data type

String

Flags

expert

Icon-Text Spacing

The space (in pixels) between the icon (if any) and the text (if any)

Scripting name

iconTextGap

Data type

int

Antialias

Draw with antialias on? Makes text smoother

Scripting name

antialias

Data type

boolean

Flags

expert

Styles

Contains the component's styles

Scripting name

styles

Data type

Dataset

Flags

bindable | expert

Behavior

Rollover

If true, the button may indicate that the mouse is hovering over it.

Scripting name

rolloverEnabled

Data type

boolean

Flags

expert

Focusable

If 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.

Scripting name

focusable

Data type

boolean

Flags

expert

Mnemonic

A single letter that will activate the button using 'ALT-mnemonic'.

Scripting name

mnemonicChar

Data type

String

Default Button

If true, this button will be activated when the user presses enter on the window.

Scripting name

defaultBtn

Data type

boolean

Flags

expert

Common

Name

The name of this component.

Scripting name

name

Data type

String

Flags

bindable

Enabled

If disabled, a component cannot be used.

Scripting name

componentEnabled

Data type

boolean

Visible

If disabled, the component will be hidden.

Scripting name

visible

Data type

boolean

Flags

bindable

Mouseover Text

The text that is displayed in the tooltip which pops up on mouseover of this component.

Scripting name

toolTipText

Data type

String

Cursor

The mouse cursor to use when hovering over this component.

Scripting name

cursorCode

Data type

int

Values

0

Default

1

Crosshair

2

Text

3

Wait

12

Hand

13

Move

4

SW Resize

5

SE Resize

6

NW Resize

7

NE Resize

8

N Resize

9

S Resize

10

W Resize

11

E Resize

Border

The border surrounding this component. NOTE that the border is unaffected by rotation.

Scripting name

border

Data type

Border

Flags

expert

Opaque

Is this button completely opaque? Most aren't, so this should usually be false.

Scripting name

opaque

Data type

boolean

Flags

expert

Data

Data Quality

The data quality code for any tag bindings on this component.

Scripting name

dataQuality

Data type

int

Flags

bindable | expert

Layout

Margin

The space between a button's text and its borders.

Scripting name

margin

Data type

Insets

Flags

expert

Horizontal Alignment

The horizontal alignment of the button's contents (text and/or image)

Scripting name

horizontalAlignment

Data type

int

Values

2

Left

0

Center

4

Right

10

Leading

11

Trailing

Horizontal Text Position

The horizontal position of the button's text relative to its image

Scripting name

horizontalTextPosition

Data type

int

Flags

expert

Values

2

Left

0

Center

4

Right

10

Leading

11

Trailing

Vertical Alignment

The vertical alignment of the button's contents (text and/or image)

Scripting name

verticalAlignment

Data type

int

Values

1

Top

0

Center

3

Bottom

Vertical Text Position

The vertical position of the button's text relative to its image

Scripting name

verticalTextPosition

Data type

int

Flags

expert

Values

1

Top

0

Center

3

Bottom

Scripting

Events

The following event sets are fired by this component. See Component Event Handlers to learn more.

mouse
mouseMotion
focus
action
propertyChange
key

 

Scripting Functions

doClick()

 

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

Parameters

none

Returns

nothing