I'm looking for some guidance on best practices for an application using Java Swing to be structured. I'm a webapp guy normally and try to follow MVC. Is MVC typical for Swing apps? If so, how?
4) There are two options to close the Java Swing application one is EXIT_ON_CLOSE and the other is DISPOSE_ON_CLOSE. 5) DISPOSE_ON_CLOSE doesn't terminate JVM if any user thread is running. 6) You can also implement a window listener to implement your closing mechanism by using System. exit() in the Swing application.
Absolutely yes. Legacy swing applications are still supported and enhanced.
EXIT_ON_CLOSE (defined in JFrame) : Exit the application using the System exit method. Use this only in applications. might still be useful: You can use setVisible(false) on your JFrame if you want to display the same frame again. Otherwise call dispose() to remove all of the native screen resources.
Following MVC is a very good idea. As far as I know there is no formal Java Swing framework doing that, they all concentrate on "View" aspect of the problem.
As far as app structure and MVC - the best framework I know is Griffon. It is not Java - it is Groovy, but that is what makes it more attractive and pretty easy to learn. Griffon to a Swing app is the same as Grails to a web app.
Check it out at http://griffon.codehaus.org/
You may find this very simple example and discussion helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With