使用groovy的swingbuilder,我想添加一个保存和退出按钮,但我不知道如何使用swingbuilder关闭帧?因为我没有将帧分配给对象,所以我不能真正执行frame.dispose()或类似的操作。
swingBuilder.edt {
frame(title: 'Calc Spell Checker', size: [800, 600],
show: true, locationRelativeTo: null,
defaultCloseOperation: 1) {
borderLayout(vgap: 5)
panel(constraints: BorderLayout.CENTER,
border: compoundBorder([emptyBorder(10), titledBorder("Spell Checking pole ${projProp.location} in project ${projProp.projectName}")])) {
tableLayout {
tr {
td {
label 'Comments: '
}
td {
scrollPane(verticalScrollBarPolicy:JScrollPane.VERTICAL_SCROLLBAR_ALWAYS) {
list listData: projProp.comments, fixedCellWidth: 600, visibleRowCount: 6
}
}
}
tr {
td {
label 'Suggestions: '
}
}
tr {
td {
button text: 'Replace'
}
td {
button text: 'Ignore'
}
td {
button text: 'Close', actionPerformed: {
f.SetVisible(false)
}
}
}
}
}
}
}发布于 2017-07-11 21:41:37
因此,要做到这一点,您只需将框架设置为构建器中的一个变量,然后对其调用dispose(),如下所示:
guiFrame = frame(title: 'Spell Checker', size: [800, 600],
show: true, locationRelativeTo: null,
defaultCloseOperation: 1) {
int commentIndex = 0
int remedyIndex = 0
borderLayout(vgap: 5)
panel(constraints: BorderLayout.CENTER,
border: compoundBorder([emptyBorder(10), titledBorder("Spell Checking pole ${projProp.location} in project ${projProp.projectName}")])) {
tableLayout {
tr {
td {
button text: 'Replace'
}
td {
button text: 'Ignore'
}
td {
button text: 'Close', actionPerformed: {
guiFrame.dispose()
}
}
}
}
}https://stackoverflow.com/questions/45034542
复制相似问题