Solved

Creating my own Event and Event Listener...

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 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:

820 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