如何在 Scala Swing 中设置按钮的大小?
我尝试使用 minimumSize
将按钮的大小设置为特定的像素大小,但看起来不起作用。
我什至尝试将其子类化并以这种方式进行操作
class SizedButton(text0: String, width0: Int, height0: Int)
extends Button(text0) {
minimumSize = new Dimension(width0, height0)
// also tried preferredSize here ...
}
,但这也不起作用。
I'm trying to set the size of a button to a specific size of pixels with minimumSize
, but it looks like it doesn't work.
I even tried to subclass it and do it this way
class SizedButton(text0: String, width0: Int, height0: Int)
extends Button(text0) {
minimumSize = new Dimension(width0, height0)
// also tried preferredSize here ...
}
but that didn't work either.
很难说出您真正想要做什么,但通常大小很大程度上取决于您使用的布局管理器。无论如何,以下内容修复了按钮的大小,例如:
It's a bit hard to tell what you're really trying to do, but generally sizing depends a lot on the layout manager you are using. Anyway the following fixes the size of a button e.g.: