如何在 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难说出您真正想要做什么,但通常大小很大程度上取决于您使用的布局管理器。无论如何,以下内容修复了按钮的大小,例如:
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.: