Listener pattern is a popular behavior pattern used in UI programming. Listener pattern provides loose coupling between event source and listener.Using Listener pattern certain objects can listen the state of the other objects (UI components).
E.g. In blackberry we can use FieldChangeListener to handle field change events of UI components and FocusChangeListener for focus change events.
In this post we will see 3 points.
1. What is Listener pattern?
2. How blackberry event listeners work?
3. How we can create a custom listener?
For creating listener design pattern we need two things
a. Event source: the component that will generate the events and will responsible for registering/ unregistering of listeners.
b. Listener: the object that will register itself to the source to listen state change of the source.
Now here is the simple implementation of custom event listener in blackberry.
Continue reading “Listener pattern in Blackberry” »