Solved

Creating my own Event and Event Listener...

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changePi Challenge 15 77
strDist challenge 35 84
json example 39 115
VB Script to add site to Java Exception List 4 18
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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:

762 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

20 Experts available now in Live!

Get 1:1 Help Now