How to set button size in Scala Swing?

I am trying to set the button size to a specific pixel size using minimumSize , but it does not seem to work.

I even tried to subclass it and do it that 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.

+4
source share
1 answer

It’s a little difficult to tell what you are actually trying to do, but usually the size depends on the layout manager you are using. In any case, the following corrections are the button size, for example:

 import swing._ import java.awt.Dimension val s = new Dimension(100, 100) val f = new Frame { contents = new FlowPanel { contents += new Button("huhu") { minimumSize = s maximumSize = s preferredSize = s } } } f.pack f.visible = true 
+7
source

All Articles