我基本上想用一个可以占用 MainFrame 中所有可用空间的 SplitPanel 来填充我的 MainFrame。我读到这样做的一种方法是将BorderPanel 添加到MainFrame,并将SplitPane 添加到BorderPanel 的中心。
object SwingApp extends SimpleSwingApplication {
def top = new MainFrame {
peer.setUndecorated(true) //with this hack it works but I don't feel like it's the purpose of the function
object splitPane extends SplitPane(Orientation.Vertical, new Button(), new Button())
contents = new BorderPanel {
import BorderPanel.Position._
val center = splitPane
layout(center) = Center
}
}
}
我的问题是,当我希望 BorderPanel 实际上填满整个框架时,它似乎采用了尽可能小的尺寸(这里为 0)。
我通过在 MainFrame 中设置找到了解决方案
peer.setUndecorate(true)
但是感觉很脏,通过阅读文档,我不知道它为什么会起作用。没有更好的方法吗?