首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Groovy SwingBuilder创建JDesktopPand/JInternalFrame组合体?

如何使用Groovy SwingBuilder创建JDesktopPand/JInternalFrame组合体?
EN

Stack Overflow用户
提问于 2018-03-20 16:17:04
回答 1查看 279关注 0票数 1

我正在尝试使用SwingBuilder创建一个Groovy应用程序。

我从http://groovy-lang.org/swing.html的基本http://groovy-lang.org/swing.html示例开始,并添加了对desktopPaneinternalFrame的调用

代码语言:javascript
复制
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)
      }
    }
  }
}

但是,这段代码只为我提供了一个空白窗口。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-21 11:20:30

看来我只需要将visiblebounds参数添加到internalFrame

代码语言:javascript
复制
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)
      }
    }
  }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49389251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档