내가 스칼라 스윙 정말 익숙하지 오전하지만 난 내 옛날 테스트 프로그램의 일부 코드를 발견 : 하워드가 당신을 DO_NOTHING_ON_CLOSE
를 사용하여
import scala.swing._
object GUI extends SimpleGUIApplication {
def top = new Frame {
title="Test"
import javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE
peer.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE)
override def closeOperation() { showCloseDialog() }
private def showCloseDialog() {
Dialog.showConfirmation(parent = null,
title = "Exit",
message = "Are you sure you want to quit?"
) match {
case Dialog.Result.Ok => exit(0)
case _ =>()
}
}
}
}
을 제안 것과
object GUI extends SimpleGUIApplication {
def top = new Frame {
title="Test"
peer.setDefaultCloseOperation(0)
reactions += {
case WindowClosing(_) => {
println("Closing it?")
val r = JOptionPane.showConfirmDialog(null, "Exit?")
if (r == 0) sys.exit(0)
}
}
}
}
감사합니다. deprecations를 제거한 후에, 이것은 트릭을했습니다. – man
도움이 되니 기쁩니다! –