Search code examples
swingscalashutdown-hookapplication-shutdown

Scala add shutdown hook to Scala swing


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.


Solution

  • Have you looked inside SwingApplication?

    https://github.com/scala/scala-swing/blob/v1.0.0-RC2/src/main/scala/scala/swing/SwingApplication.scala#L16

    There is a main or a startup to register Runtime.addShutdownHook.

    Or there is a shutdown template method if that's all you mean.