Graphical User Interfaces
-
Upload
independent -
Category
Documents
-
view
1 -
download
0
Transcript of Graphical User Interfaces
Four techniques for handling event
• Use current class as the listener
• Define a new class and use it as the listener
• Use an anonymous class as the listener
• Use an inner anonymous class as the listener
When to use each technique?
• In most cases, you can use any of these four techniques for your app. So, which technique should you use? In most cases, that’s largely a matter of personal preference.
• However, if you need to wire the exact same event handler to multiple widgets, you should reduce code duplication by using one of the first three techniques.
• In general, I recommend using the technique that result in the most readable and maintainable code.
• I also recommend using the same technique throughout an app whenever possible for the sake of consistency.