Q&A
Q1: | Can a program's event-handling behavior be put into its own class instead of including it with the code that creates the interface? |
A1: | It can, and many programmers will tell you that it's a good way to design your programs. Separating interface design from your event-handling code enables the two to be developed separately—the SwingColorTest application today shows the alternative approach. This makes it easier to maintain the project; related behavior is grouped and isolated from unrelated behavior. |
Questions
1: | If you use this
in a method call such as addActionListener(this), what object is being registered as a listener
?
|
2: | What is the benefit of subclassing an adapter class such as WindowAdapter ... |
Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.