我基本上想用一个SplitPanel填充我的MainFrame,它将占用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)但它感觉很脏,而且通过阅读文档,我不知道它为什么会起作用。有没有更好的办法?
发布于 2014-09-12 23:50:55
您可以使用BorderFactory添加边框并指定厚度(此处为10)。
panel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 10));https://stackoverflow.com/questions/25796628
复制相似问题