By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,470 Members | 1,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,470 IT Pros & Developers. It's quick & easy.

Swing Design Patterns

P: n/a
Having been traumatised many years ago when using MFC/C++ to develop
front-end code, I've religiously avoided GUI work since and stuck to
back-end / server-side projects. So I'm a bit of a novice when it
comes to designing Swing-based applications.

I'm now having to do more and more GUI work to support my current
projects, so I started looking for tutorial / best-practices materials
on the net. I was somewhat surprised to find that there's a dearth of
this sort of information. A quick Google search of 'swing best
practices' comes up with a couple of books and a few sites that
generally just re-iterate the APIs.

What I'm looking for are some Swing design best-practices akin to the
ones that are readily available for plain OO, J2EE design, etc.

Are there any?

For example:
- what's the best way to implement a wizard?
- how to minimise dependencies in a complex GUI?
- etc

Any pointers to useful books, sites, articles, example apps, etc.
appreciated.

- sarge
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
sa*********@hotmail.com (Chris) wrote in message news:<56**************************@posting.google. com>...
[snipped...]
What I'm looking for are some Swing design best-practices akin to the
ones that are readily available for plain OO, J2EE design, etc.
What you have to understand is that Object Orientation and Enterprise
computing are both 'methodologies', to varying degrees, as well as just
technologies.

Swing is just a tool for writing UI software - it isn't a different
way of structuring and designing software in itself. As such, while
there are plenty of books and on-line resources devoted to how to
create good user interfaces (HCI, etc) I suspect there is little on
how to structure their design from a source code viewpoint (little
which is specific to UI coding anyway!)
Are there any?

For example:
- what's the best way to implement a wizard?
I suspect CardLayout would fit the job.
- how to minimise dependencies in a complex GUI?
You mean from a HCI viewpoint (ie. designing elegant interfaces) or
from a coding point of view? The issues surrounding compartmental-
ising and re-using Swing code are probably identical to handling any
other complex structures. You might want to take a look at the way
UI components work as Java Beans, as this offers a formalised way of
linking components together. Also take a look at the 'model'
interfaces which are used to connect Swing components to 'outside'
data structures.
- etc

Any pointers to useful books, sites, articles, example apps, etc.
appreciated.


Its not entirely clear whether you want a guide to good interface
design, a "How to...?" on creating user interfaces (like a Wizard)
or some sort of design methodology specific to writing GUI code...
-FISH- ><>
Jul 17 '05 #2

P: n/a
Perhaps I didn't make my point very clear.

What I'm after are some design patterns for writing Swing code.

As an analogy: you can look at the Java APIs or Java in a Nutshell,
but it doesn't tell you how to minimise inter-dependencies between
classes and avoid exposing implementation details using
getters/setters - for that you'd use the Builder pattern.

Similarly, I can look at the Swing APIs or examples on java.sun.com,
but they don't tell me how to use those components effectively, i.e. I
KNOW how to use a JTabbedPane in isolation for example, what I'm less
clear on is the BEST way to use it in the context of a large, complex
GUI.

If the examples of code I've seen of large applications are the norm
then I think I'll not bother, because they were basically
unmaintainable spaghetti, harking back to the dark days of MFC/C++
that I mentioned. I'm sure there must be better design idioms
relating specifically to Swing (or any event-based Windows-style API)
that promote good OO principles.

So, where are those sites that allow me to short-circuit my knowledge
of how to design GOOD Swing apps? Or does anyone know/have any
examples of well-designed (in their opinion) large-ish Swing apps?

- sarge
Jul 17 '05 #3

P: n/a

You can refer Swing Second Edition, by Matthew Robinson and Pavel vorobiev.

http://www.manning.com/robinson2/index.html

Thanks,
Sameer

Chris wrote:
Perhaps I didn't make my point very clear.

What I'm after are some design patterns for writing Swing code.

As an analogy: you can look at the Java APIs or Java in a Nutshell,
but it doesn't tell you how to minimise inter-dependencies between
classes and avoid exposing implementation details using
getters/setters - for that you'd use the Builder pattern.

Similarly, I can look at the Swing APIs or examples on java.sun.com,
but they don't tell me how to use those components effectively, i.e. I
KNOW how to use a JTabbedPane in isolation for example, what I'm less
clear on is the BEST way to use it in the context of a large, complex
GUI.

If the examples of code I've seen of large applications are the norm
then I think I'll not bother, because they were basically
unmaintainable spaghetti, harking back to the dark days of MFC/C++
that I mentioned. I'm sure there must be better design idioms
relating specifically to Swing (or any event-based Windows-style API)
that promote good OO principles.

So, where are those sites that allow me to short-circuit my knowledge
of how to design GOOD Swing apps? Or does anyone know/have any
examples of well-designed (in their opinion) large-ish Swing apps?

- sarge


~ Let us linux ~
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #4

P: n/a
>
Any pointers to useful books, sites, articles, example apps, etc.
appreciated.

A useful book for you could be
Graphic Java: Mastering the JFC (Swing), Volume II
Prentice Hall

When I started in Java GUI development, I found the most and best
informations in this comp.lang.java.* groups.

Klaus
Jul 17 '05 #5

P: n/a
Here are a bunch of points regarding Swing coding :
http://www.javapractices.com/TableOfContents.cjp#Swing

The site also has an example Swing app :
http://www.javapractices.com/Topic170.cjp
(The source is available for a small fee)

Chris wrote:
Having been traumatised many years ago when using MFC/C++ to develop
front-end code, I've religiously avoided GUI work since and stuck to
back-end / server-side projects. So I'm a bit of a novice when it
comes to designing Swing-based applications.

I'm now having to do more and more GUI work to support my current
projects, so I started looking for tutorial / best-practices materials
on the net. I was somewhat surprised to find that there's a dearth of
this sort of information. A quick Google search of 'swing best
practices' comes up with a couple of books and a few sites that
generally just re-iterate the APIs.

What I'm looking for are some Swing design best-practices akin to the
ones that are readily available for plain OO, J2EE design, etc.

Are there any?

For example:
- what's the best way to implement a wizard?
- how to minimise dependencies in a complex GUI?
- etc

Any pointers to useful books, sites, articles, example apps, etc.
appreciated.

- sarge


Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.