我正在尝试使用SwingBuilder创建一个Groovy应用程序。
我从http://groovy-lang.org/swing.html的基本http://groovy-lang.org/swing.html示例开始,并添加了对desktopPane和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)
}
}
}
}但是,这段代码只为我提供了一个空白窗口。
发布于 2018-03-21 11:20:30
看来我只需要将visible和bounds参数添加到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)
}
}
}
}https://stackoverflow.com/questions/49389251
复制相似问题