posted 22 years ago
Hi Kavita,
I think the answer relates to what source the MouseEvent is coming from. If we have set the Panel to be the MouseEvent listener then 1 would be correct. If we set the Frame to be the MouseEvent listener then 2 would be correct.
The layout here is also important. If we place a Panel into a Frame, the panel will end up in the BorderLayout.CENTER position of the frame which will in effect take up the entire Frame. Therefore, the frame as a mouse listener will never get any events because the Panel is in front of it! This is probably the logic being used by the tester.
Regards,
Manfred.