You Are Here:
TopJazzSwing > Swing Msg58750

Swing

Re: Att : MVC and Swing
Date: Tue, 6 May 2003 11:02:31 +0000 (UTC)
Newsgroups: comp.lang.java.gui
Size: 1,160 bytes
"Tommy Strømhaug" <email-address-deleted> writes:
> Do anybody have a small, simple example on how to implement a java/swing
> prog according to the MVC modell ?
Swing uses a variant of MVC, which is explained in the Swing
architecture article on the Sun "Swing Connection" page. Swing does not
do the "pure" MVC thing.
You can find many examples of using Swing's widget/model combination in
Sun's GUI tutorial.
> I am not quite sure how to split my program. Isnt it best to have the model
> in a separate file, so that it easily can be exchanged ?
Already because of the fact that it is most likely a public class, it
has to end up in an own file (Java's rule about files and public
classes).
> How about the View
> and the Controller ?
They do not exist in this form in Swing. So you have to make a
decission.
- You can use Swing's architecture, which works for practical purposes, but is not "pure" MVC.
- You "fight the system", and try to squeeze "real" MVC out of Swing.
- You implement an own GUI system, exactly doing MVC.
> The examples i have seen doesnt in a clear division between these parts.
If it just uses Swing, it can't.
/Thomas

Site Categories:
• Broadway
• Child Song
• Christian Music
• Classical Music
• Country Music
• Dance
• Gospel Music
• Guitar Music
• Jazz
• Karaoke
• Lyric
• Metal Music
• Music
• Music Download
• Music Video
• New Age
• Rap Music
• Reggae
• Rock
• Wedding Song
• World Music