A javax.swing.JButton is returned, unless the user passes in a subclass of JButton as the value argument, in which case the value argument is returned.
See also: JComponent
No child content is accepted in a button.
button creates a slider-bar type widget.
//TODO add an image
//TODO describe how to fire code on a button press
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
This will run as a Groovy script.
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