Solved

Creating my own Event and Event Listener...

Posted on 1998-04-08
2
176 Views
Last Modified: 2010-08-05
I have a Reusable StatusBar class which I created.  I want to be able to add an EventListener for it so that whenever another class wants to set the text in the status bar, it can do so via the StatusBarListener.  How can I do this?
0
Comment
Question by:bjg
2 Comments
 
LVL 1

Accepted Solution

by:
dufort earned 50 total points
ID: 1233994
Why using Events and EventListeners?

Simply use a public method in StatusBar that sets its text and refreshes it:

    public void setText(String s)

and add a reference to your status bar in the classes that want to make use of it. It's that simple.

Don't forget that in this actual case, it is the StatusBar that "listens" to other components; if the other components were listening to the StatusBar (the opposite situation), event listeners would be needed.

0
 

Author Comment

by:bjg
ID: 1233995
I don't want any of my gui components to need knowledge of each other.  So I don't want references of other gui components inside each other.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now