Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing Program Structure [closed]

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?

like image 400
cfans Avatar asked Jul 01 '10 19:07

cfans


People also ask

How do I close a Swing application?

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.

Is Java Swing still used 2021?

Absolutely yes. Legacy swing applications are still supported and enhanced.

How do I close a program in JFrame?

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.


2 Answers

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/

like image 93
Eugene Ryzhikov Avatar answered Oct 05 '22 22:10

Eugene Ryzhikov


You may find this very simple example and discussion helpful.

like image 22
trashgod Avatar answered Oct 05 '22 22:10

trashgod