Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does anyone use java.util.Observer/Observable in Swing?

 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just starting learning Swing, and I was wondering if anyone actually uses java.util.Observer and java.util.Observable when writing MVC applications in Swing. It seems much cleaner to me for all relevent methods in both the Views and the Models to deal with application specific Model and View interfaces instead of the general Observer/Observable methods.

So what do people usually do?

Thank you,
Yuriy
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made my own event publisher before I stumbled across Observer / Observable. It supports custom listener interfaces, arbitrary method parameters and return types and unsychronized life cycles. It takes a bit more typing (copy paste ) but does everything I need.
[ January 04, 2006: Message edited by: Stan James ]
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there something you want to do for which events aren't suitable to provide Observer/Publish-Subscribe functionality?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use them if you wish, but note that there is nothing special about them: they are not used in the API and if you look at their source code there is not much to them! There is also no common practice of using them widely in Swing app code, from what I'e seen. In short, no big wup.
[ January 05, 2006: Message edited by: Jeff Albrechtsen ]
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All right, thank you for the replies everyone!

Yuriy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic