我有这个:
def top = new MainFrame {
contents = new GridBagPanel {
def constraints(x: Int, y: Int, .... ) {...}
add(btn("A"), constraints(0, 0))
private def btn(name: String): Button = new Button() {
text = name
}
}
并且它没有显示button
的名称,但是当我以这种方式书写时,它很好:
def top = new MainFrame {
contents = new GridBagPanel {
def constraints(x: Int, y: Int, .... ) {...}
add(new Button("A"), constraints(0, 0))
}
}
我真的不明白为什么?
答案 0 :(得分:2)