For events like mouse events, e.getSource() refers to component which fired the event. So say if you have a button and attach a MouseListener to it like below .... then the MouseEvent e.getSource would be a Button.
The casting is make sure the event is indeed a button and not object.
Rob Prime wrote:This particular subject is discussed in its Swing section mostly.
Joined: Jul 01, 2009
Rob Prime wrote:Linus, you've been asking quite a few starter questions lately. Perhaps it is a good idea to read through the Java Tutorial. This particular subject is discussed in its Swing section mostly.