posted 23 years ago
Mohit,
Seems to be some confusion here:
The question asked about ComponentListener, not about ContainerListener.
ComponentListener gets ComponentEvents, which are sent when the component in question is resized, or its visibility changes (gets uncovered perhaps) etc. This certainly makes sense for a TextArea.
ContainerListeners are not specified for TextAreas, and make no sense, because a TextArea is not a Container and you cannot add buttons to it etc.
The MouseListener and MouseMotionListeners are specified because you might reasonably want to know when the mouse moves over the TextArea or clicks on it. The basic text-editing capability of the component is built-in, that's true, and I assume it uses these listeners. But that doesn't mean you can't add more listeners of your own, even of the same kind, to add additional behavior.
For the sake of example, you might create a TextArea that displays its text for reading, but when the mouse moves over it, it reformats the text for editing, for example by showing markup tags, much as happens when you post on JavaRanch. You would do this by adding your own Mouse listeners to those already there.
The question originally asked was: why is ActionListener not included? I guess the answer is that ActionEvent is conceptually the class of events used to signal that the end-user has performed some component-specific GUI-operation like push the button or drag the slider or select the menu-item. And there is no such control-operation intended in the design of TextArea, except of course editing the text, which has its own kind of event and listener. So ActionEvent is not meaningful, or needed.
(Sure hope somebody with more experience than I reads this and vets it).