Exercise 13.3.2. JButton MVC.
Solution.
How can a button still be considered a component under the MVC model? This is a good question. The
JButton
class acts as a wrapper class and hides the model-view-controller details (Fig. Figure 13.3.3). When you instantiate a JButton
, you still get a single instance. Think of it this way: Your body consists of several systems that interact (internally) among themselves, but it’s still one body that other bodies interact with as a single object.