boukaka
asked on
notificationlistener
Does anyone know of a good tutorial for beginners on how to create an interface with a notification listener that listens to a class and how to observe it from another class?
I have a class called ODSLoader that I need to listen to - I have the basic structure of the interface (I think) but I have no idea how to code it to actually listen to ODSLoader.
public interface Notifier {
public interface NotificationListener {
public void onNotificationPosted();
}
public void addListener(NotificationLi stener listener);
public void removeListener(Notificatio nListener listener);
}
I then have another class with a progress bar that needs to be notified when to progress but I have no idea how to do that either...
This is my progress bar
progressBar = new JProgressBar(0,100);
progressBar.setValue(0);
springLayout.putConstraint (SpringLay out.NORTH, progressBar, 12, SpringLayout.SOUTH, btnProcess);
springLayout.putConstraint (SpringLay out.WEST, progressBar, 10, SpringLayout.WEST, frame.getContentPane());
springLayout.putConstraint (SpringLay out.EAST, progressBar, -10, SpringLayout.EAST, frame.getContentPane());
frame.getContentPane().add (progressB ar);
Can anyone point me in the right direction or show me how to code it?
Thanks
I have a class called ODSLoader that I need to listen to - I have the basic structure of the interface (I think) but I have no idea how to code it to actually listen to ODSLoader.
public interface Notifier {
public interface NotificationListener {
public void onNotificationPosted();
}
public void addListener(NotificationLi
public void removeListener(Notificatio
}
I then have another class with a progress bar that needs to be notified when to progress but I have no idea how to do that either...
This is my progress bar
progressBar = new JProgressBar(0,100);
progressBar.setValue(0);
springLayout.putConstraint
springLayout.putConstraint
springLayout.putConstraint
frame.getContentPane().add
Can anyone point me in the right direction or show me how to code it?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think googling for java observer pattern will get you a lot of useful links.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, so I have to go figure out how to pass an "instance" and I think I'm good.
ASKER
Thank you very much for all your help!
@boukaka,
I gave you quite a bit of the code that you needed in my first comment, and zzynx followed up with some more in another comment.
Do you think that the points should have been split between the two of us?
I gave you quite a bit of the code that you needed in my first comment, and zzynx followed up with some more in another comment.
Do you think that the points should have been split between the two of us?
I agree that a split would have been more fair.
You can ask for a reopen of this question and once it is, you can close it again giving both of us points.
You can ask for a reopen of this question and once it is, you can close it again giving both of us points.
ASKER
Oh sorry, just noticed this. Where to I ask for a re-open?
Thanks,
Thanks,
ASKER
Points have been split 50/50 now. Sorry about that.
No worries, thanks for resolving it! :)