Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2006

Tip: Looking for answers? Try searching our database.

looking for complex code example for best swing / MVC practices

Thread view: 
antoine - 30 Aug 2006 06:01 GMT
Hello,

I've been using Swing to develop complex GUI (standalone applications)
for quite some time and feel confident with the language, the
components, the layout, all the graphic part basically, however I get
the feeling I still can't grasp the good way of dealing with MVC /
separating business logic from graphic elements.

I've been searching for a complete & complex example application with
good design, from which I could learn & realize my mistakes, but
couldn't find any through google so far...

would anyone know of such app ? maybe an open source project ?

thanks for any info you might contribute...

-Antoine
Karsten Lentzsch - 30 Aug 2006 07:30 GMT
> [...]
> I've been searching for a complete & complex example application with
> good design, from which I could learn & realize my mistakes, but
> couldn't find any through google so far... [...]

Martin Fowler describes desktop patterns that I found useful
for working with Swing, especially "Presentation Model" and
the Model-View-Presenter (MVP) variants, and a bunch of other
less important patterns such as Presentation Chooser or
Event Aggregator.

Martin motivates these patterns and why one would separate
the presentation logic from the presentation in a longer text.
Just google for "Organizing Presentation Logic".

I provide presentations that describe the architecture
of the JGoodies tools and demos. These slides complement
Fowlers texts and pattern descriptions; my focus is on
the concrete Swing implementation.

My favorite pattern for Swing is "Presentation Model",
because Swing already includes a good portion of the
synchronization necessary for using this pattern.
The free JGoodies Binding tutorial contains source
code examples for using "Presentation Model" with Swing.
And so you can get the following for free: Fowlers motivation,
and his pattern catalog, my slides with additional diagrams,
smaller Swing source code examples. My presentations are here:
http://www.jgoodies.com/articles/

-Karsten
unomystEz - 02 Sep 2006 15:41 GMT
Karsten,

  I looked at your presentations and they are very good, thanks.  What
about when dealing with extremely high performance GUI applications
that have a lot of complexity at the model layer, enough to warrant
writing a custom event dispatch/firing mechanism - as opposed to using
the built-in Java dispatching.  ie, consider a stock application that
monitors 2000 stocks and stock prices can change very often, in total
maybe 40 updates a second a realized, then up to 30 swing components
per stock needs to be notified which could result in a lot of firing
and handling per second.  What are your thoughts on this?

> > [...]
> > I've been searching for a complete & complex example application with
[quoted text clipped - 27 lines]
>
> -Karsten
Karsten Lentzsch - 03 Sep 2006 12:14 GMT
> [...] What
> about when dealing with extremely high performance GUI applications
> that have a lot of complexity at the model layer, [...] in total
> maybe 40 updates a second a realized, then up to 30 swing components
> per stock needs to be notified which could result in a lot of firing
> and handling per second.  What are your thoughts on this?

Repainting costs more than firing and listening to events.

If performance is critical, identify the hot spots that
consume the time, and I guess it'll be drawing and potentially
revalidation of the views. Check the standard tricks to
improving the painting performance: invalidate only necessary
portions, honor the clipping rectangle, consider using
a customized repaint manager.

Two years ago I worked with apps that fired and observed
10 times more events than are handled by my recent code.
(Before 1.0 the JGoodies Binding lacked the BeanAdapter)
Reducing the number of events and handlers did result
in no perceived performance improvements. The motivation
for reducing the number of events and handlers was debugging.

If you have more concerns about performance, you may
post at the forums at javadesktop.org. It seems to me
that the audience is larger there, and that you get
feedback from AWT/Swing team members there.

-Karsten


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.