wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Correct Way??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Correct Way???" Watch "Correct Way???" New topic
Author

Correct Way???

Jim Schneider
Greenhorn

Joined: Oct 22, 2003
Posts: 3
Hello,
I am a java newbie but not to programming and trying to learn and put a desktop application together. I would like to know is there a right/wrong ways to open/start a Java desktop application.
My thoughts are as follows:
Have an "application manager object" that basically handles the entire
application. This object would be created in the main function of the
class.
This object would then handle everything from there open new frames build
new objects from an init() function called from the main function.
When the init control is returned to the init functions the application
would naturally end.

Is this the correct way to handle a desktop application and will when the init() function opens a window will the function keep control until that window is closed???

TIA
-Jim
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

It depends on what you mean my "handles the entire application". Assuming you only have one main window, you will probably just want to extend JFrame. There you will create all your controls, hook up listeners, etc. You can just instantiate your derived JFrame in the main method and put the main method in that class. What more are you thinking the application manager class should do?
Chet Haase
author
Ranch Hand

Joined: Aug 16, 2007
Posts: 32
It's worth noting that a framework to manage a Swing application is one of the big drivers behind the Swing Application Framework project ( https://appframework.dev.java.net/ ). It has the concept of an "Application" and handles calling back into your code to set things up (on the right GUI thread) and shut things down, handles persistent app info, resource injection...

Chet.


Book: <a href="http://filthyrichclients.org" target="_blank" rel="nofollow">http://filthyrichclients.org</a> <br />Java: <a href="http://weblogs.java.net/blog/chet" target="_blank" rel="nofollow">http://weblogs.java.net/blog/chet</a> <br />Humor: <a href="http://chetchat.blogspot.com" target="_blank" rel="nofollow">http://chetchat.blogspot.com</a>
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Kind of like Eclipse RCP
Chet Haase
author
Ranch Hand

Joined: Aug 16, 2007
Posts: 32
Yes and No: Eclipse RCP is more comparable to the much larger NetBeans Platform framework. That system has all kinds of large-app facilities, like modules, updates, etc. The Swing app framework is much smaller and more focused on basic, boilerplate needs of even small and medium sized applications.

Chet.
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

I've been spending way too much time with Eclipse RCP. I didn't know this Swing Application Framework even existed. Looks pretty cool. I'll have to check it out. Thanks.
Romain Guy
author
Ranch Hand

Joined: Sep 18, 2007
Posts: 47
Also check out NetBeans RCP. As Chet said, it comparable to Eclipse RCP but for Swing. The Swing Application Framework has a much narrower target in mind.
Jim Schneider
Greenhorn

Joined: Oct 22, 2003
Posts: 3
Thanks Chet
I checked out the application framework and looks like what I am trying to do.
-Jim
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Correct Way???