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 / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

creating my own Events?

Thread view: 
Josef Garvi - 08 Mar 2004 08:21 GMT
Is there a recommended way of implementing events?

I have a data object, that should inform my GUI whenever it's contents
changes, so that the GUI can update it's view. What is the best way of
implementing this? Should I use the listener system? I know how to add
listeners, but not how to fire the events.

Ideally, my system would queue the events in some way so that duplicate
messages could be deleted. In Win32 I used to do this using the PostMessage
and PeekMessage commands.

Signature

Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty

Steve W. Jackson - 08 Mar 2004 20:23 GMT
>:Is there a recommended way of implementing events?
>:
[quoted text clipped - 6 lines]
>:messages could be deleted. In Win32 I used to do this using the PostMessage
>:and PeekMessage commands.

Visit your friendly neighborhood API and look up PropertyChangeEvent in
the java.beans package.  And PropertyChangeListener,
PropertyChangeSupport or its descendant SwingPropertyChangeSupport.

This is where you can notify interested parties of changes to bound
properties.  So if you want to use an event mechanism, it's a good way
to go.  Your "data object" will likely need to carry one of the
"support" objects as a member variable.  It will need to include methods
to add and remove property change listeners.  And when properties of
interest change, it'll need to be able to have its support object fire
the notification to all registered listeners, which will carry the
PropertyChangeEvent with details.

If you need additional complexity -- that is, queueing to remove dupes,
etc. -- it can be built around this very simple approach.

HTH.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

Josef Garvi - 10 Mar 2004 06:59 GMT
>>:Is there a recommended way of implementing events?
>
> Visit your friendly neighborhood API and look up PropertyChangeEvent in
> the java.beans package.  And PropertyChangeListener,
> PropertyChangeSupport or its descendant SwingPropertyChangeSupport.
> ...

Thanks.

Signature

Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty



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.