Creating a superclass that incorporates a HyperLinkistener and a MouseAdapter
I have one class called HyperlinkEventMonitor that implements a HyperlinkListener. I want to extend this class so that it handles both hyperlink events and mouseevents. I tried creating a superclass but I'm not doing this right because I can't compile the code. Can someone show me how to do this.
For example: I tried
class MouseHyperLink extends HyperlinkEventMonitor, implements MouseListener {
}
开发者_运维知识库But this is wrong.
How can I do this?
Thank you,
Elliott
Without further information on the error message I'll guess that it is the comma-character that messes things up. Try removing the comma-character:
class MouseHyperLink extends HyperlinkEventMonitor implements MouseListener {
// ...
}
Also, make sure that you implement all methods of MouseListener
.
If you don't want to implement all methods in MouseListener
(and defer that to the subclass) you'll have to make the class abstract:
abstract class MouseHyperLink extends HyperlinkEventMonitor
implements MouseListener {
}
精彩评论