How does application/JVM know which classes if implemented key handling interfaces ? Does it use java Reflections or does it check all the classes for methods ?
How can a application or executing JVM understanding to deliver the user event or call the specific methods on a class that implemented the keylistener interface. Does it look at all the classes if those methods are implemented or how does it know which classes implmented keylistener interface ?
If you dont implement the keylistener Interface for a class but still implmentation all its methods开发者_开发问答. Do the class still process the user event occurred ?
If you want to handle particular kind of events for a screen in your blackberry application, then you will need to create a class that implements the particular event interface and register it with your screen.
e.g if you want to handle key events you will need to create a class that implements the KeyListener interface and add register the KeyListener with your screen.
There is example code in the link.
Note: You can create an inner class or an anonymous class rather than having the Screen class implement the interface
Just creating the methods in your MainScreen
class but not implementing the interface or registering it, will not work.
to proceess event you are to add listener to event producer (e.g button). after event occured producer will call all registered listeners in a loop, passing event object as param.
精彩评论