...
The selected property is not very interesting for the Button class, as it is not user changeable. This is mostly a leaky abstraction for checkBox and radioButton
Examples
//TODOThis will run as a Groovy script.
| Code Block | ||
|---|---|---|
| ||
import groovy.swing.SwingBuilder
import java.awt.Insets
import javax.swing.JFrame
println 'hello, world'
new SwingBuilder().frame(title: 'demo using buttons', defaultCloseOperation: JFrame.EXIT_ON_CLOSE, show: true, pack: true) {
vbox() {
button(action: action(name: 'basic', closure: {println "basic"}))
button(action: action(name: 'mnemonic', mnemonic: 'P', closure: {println 'with mnemonic'}))
button(action: action(name: 'default', defaultButton: true, closure: {println 'this is the default button'}))
button(borderPainted:false, action: action(name: 'unpainted border', closure: {println 'unpainted border'}))
button(contentAreaFilled:false, action: action(name: 'unfilled content area', closure: {println 'unfilled content area'}))
button(focusPainted:false, action: action(name: 'unpainted focus (select it and you\'ll see)', closure: {println 'unpainted focus'}))
button(margin: new Insets(5, 10, 15, 20), action: action(name: 'margins', closure: {println 'margins'}))
}
}
|
//TBD further examples for icon related behaviour
Observable Attributes
- defaultCapable
- selected - via synthetic observation
- action
- borderPainted
- contentAreaFilled
- disabledIcon
- disabledSelectedIcon
- displayedMnemonicIndex
- focusPainted
- hideActionText
- horizontalAlignment
- horizontalTextPosition
- icon
- iconTextGap
- label
- margin
- mnemonic
- model
- pressedIcon
- rolloverEnabled
- rolloverIcon
- rolloverSelectedIcon
- selectedIcon
- text
- verticalAlignment
- verticalTextPosition