Have you looked inside SwingApplication
?
There is a main
or a startup
to register Runtime.addShutdownHook
.
Or there is a shutdown
template method if that's all you mean.
Pregunta
I have used shutdown hooks before in java apps however not in java swing. I want to add a shutdown hook to scala swing app. Scala swing has no main method so i have no idea how to implement it I want to run a few methods just before closing so if there other ways beside the shutdown hook please suggest.
Solución
Have you looked inside SwingApplication
?
There is a main
or a startup
to register Runtime.addShutdownHook
.
Or there is a shutdown
template method if that's all you mean.
Otros consejos
Do you mean something similar to this? :
class MyFrame extends Frame {
peer.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE)
override def closeOperation() {
println("Hello")
exit(0)
}
}
Hello
will be printed when the Frame is closed.