Solved

Creating my own Event and Event Listener...

Posted on 1998-04-08
2
178 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

776 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