| ||||
Copyright 1999 Sams Publishing |
|
Extending Thread and JComponent? |
Using the event handling thread to run the timer proved to be an impossible idea. Another thread has to be used to run the timer. Based on what has been explored in earlier chapters, it would be nice if SecondCounter could inherit from both JComponent and Thread , as illustrated in Figure 4.4. |
Figure 4.4: Inheriting from both JComponent and Threadimpossible in Java! | |
Because multiple inheritance is not permitted in Java, this approach wont work. It is most important that SecondCounter IS-A Component so that it can be added to a Container , like JPanel . How can it also allow a thread to run within it? |
| |||
Toc |