It's very easy to generate the whole anonymous implementation of some interface, for example, of some listener, by using the SmartType code completion. For example, you may type
  Component component;
  component.addMouseListener(
    new <caret is here> 
  );
and press &shortcut:SmartTypeCompletion; to see what happens.