Say I have a swing GUI, and I want to listen MouseEvents. Who do you think should be the Listener class, who should be responsible? What is the best-or preferr
anonymous classes are mainly used for listeners. If you know that you'll have a particular listener registered just once and it's rather short, then you can use anonymous class.