开发者

Scala Swing component sizing

Scala is an awesome language, but unfortunately the library documentation is lacking. How do I change the initial size of a component? I have nothing on it (intentionally), but would like it to be a certain size anyway. I currently have

...
contents = new BoxPanel(Orientation.Vertical) {
    contents += new BoxPanel(Orientation.Horizontal) {
        contents += buttons(0)
        contents += buttons(1)
        contents += buttons(2)
    }
    contents += new BoxPanel(Orientation.Horizontal) {
        contents += buttons(3)
        contents += buttons(4)
        contents += buttons(5)
    }
    contents += new BoxPanel(Orientation.Horizontal) {
        contents += buttons(6)
        contents += buttons(7)
        contents += buttons(8)
    }
   开发者_开发知识库 border = Swing.EmptyBorder(10, 10, 10, 10);
}
...

buttons is an array of scala.swing.Buttons. Unfortunately they all show up very small when the application is run. I'd like them to be about 60x60 pixels each, though any reasonably large square would suffice.


Have you tried setting a preferred size on the buttons?

buttons foreach { _.preferredSize = new Dimension(60, 60) }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜