Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala Swing组件大小调整_Swing_Scala_Components - Fatal编程技术网

Scala Swing组件大小调整

Scala Swing组件大小调整,swing,scala,components,Swing,Scala,Components,Scala是一种很棒的语言,但不幸的是缺少库文档。如何更改零部件的初始尺寸?我没有在它(有意),但希望它是一个特定的大小无论如何。我现在有 ... contents = new BoxPanel(Orientation.Vertical) { contents += new BoxPanel(Orientation.Horizontal) { contents += buttons(0) contents += buttons(1) con

Scala是一种很棒的语言,但不幸的是缺少库文档。如何更改零部件的初始尺寸?我没有在它(有意),但希望它是一个特定的大小无论如何。我现在有

...
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);
}
...

按钮
是scala.swing.Button的数组。不幸的是,当应用程序运行时,它们都显示得非常小。我希望每个按钮的大小大约为60x60像素,不过任何较大的正方形都足够。

您是否尝试过在按钮上设置一个首选大小

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

这更像是一个swing问题,但这里有一些指导:常规swing和Scala的Scala.swing包装库之间有很大区别。不幸的是,这似乎不起作用。按钮很小。听起来布局有问题。您可以在构建每个按钮时尝试设置preferredSize(例如,
new button{preferredSize=new Dimension(60,60)
),或者在设置首选大小后重新验证外部BoxPanel。仍然不走运。我最终回到了Java Swing库,我很了解这些库。我已经使用它们了。