I am trying to create a Groovy MDI application using SwingBuilder.
I've started with the basic SwingBuilder example at http://groovy-lang.org/swing.html and added calls to desktopPane
and internalFrame
:
import groovy.swing.SwingBuilder
import java.awt.BorderLayout as BL
count = 0
new SwingBuilder().edt {
frame(title: 'Frame', size: [300, 300], show: true) {
desktopPane() {
internalFrame() {
borderLayout()
textlabel = label(text: 'Click the button!', constraints: BL.NORTH)
button(text:'Click Me',
actionPerformed: {count++; textlabel.text = "Clicked ${count} time(s)."; println "clicked"}, constraints:BL.SOUTH)
}
}
}
}
However, this code only gets me a blank window.
Looks like I just needed to add visible
and bounds
parameters to the internalFrame
import groovy.swing.SwingBuilder
import java.awt.BorderLayout as BL
count = 0
new SwingBuilder().edt {
frame(title: 'Frame', size: [300, 300], show: true) {
desktopPane() {
internalFrame(visible: true, bounds: [25, 25, 200, 100]) {
borderLayout()
textlabel = label(text: 'Click the button!', constraints: BL.NORTH)
button(text:'Click Me',
actionPerformed: {count++; textlabel.text = "Clicked ${count} time(s)."; println "clicked"}, constraints:BL.SOUTH)
}
}
}
}