Custom Event and Listener Declaration ???

Posted on 2003-02-20
Medium Priority
Last Modified: 2010-03-31
Is there a good tutorial somewhere on how to create custom events and listeners?  I realize I'll be using EventObject, and EventListener, but I'm looking for a good, working example.

I've reviewed the short tutorial at http://javaalmanac.com/egs/java.util/CustEvent.html and found it somewhat lacking.  Thanks in advance for you help.
Question by:west17m
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 86

Expert Comment

ID: 7992727
In what respects is it lacking - maybe we can help?

Author Comment

ID: 7994033
The tutorial that the above site does the job, but it is in three classes (Event, Listener, Other).  I'm looking for something concise that will end up being similar to implement like ActionListener with the ActionPerformed method.
LVL 86

Accepted Solution

CEHJ earned 200 total points
ID: 7995456
It can't get any more concise as far as i can see. The reason it's less concise than simply receiving events through actionPerformed is that you have to

a. Create your own event instead of just listen for it
b. Create a list of listeners instead of merely add to an existing one

Author Comment

ID: 8466154
I just got done writing a blackjack program that was based on custom events and listeners.  The files are short and sweet and simply allow objects to communicate through a function fireMyEvent(obj,obj,String) that sends from one obj to another some String that's a message.

Shoot me an email at travis@wsor.net, and I'll send you the source if you want.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question