Solved

Creating my own Event and Event Listener...

Posted on 1998-04-08
2
180 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
[X]
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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb entity bean example issue 2 43
Delphi Firemonkey: if the Sms contain special characters it won't send it 3 84
DTD and JAVA versions 1 59
Java pass by reference 3 74
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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 …
Suggested Courses

759 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