When I implement an interface Eclipse tells me to add all implemented methods.
Since not all of them are usually needed, is there a way to delete methods inherited from the interface instead of having an empty body? It bothers me a bit to have this useless code floating around.
A good example for this is the KeyListener
interface.
jTextComponent.addKeyListener(new KeyListener()
{
@Override
public void keyTyped(KeyEvent e)
{
}
@Override
public void keyPressed(KeyEvent pressedEvent)
{
System.out.println("Pressed!");
}
@Override
public void keyReleased(KeyEvent arg0)
{
}
});
I want to write the following or similar:
jTextComponent.addKeyListener(new KeyListener()
{
@Override
public void keyPressed(KeyEvent pressedEvent)
{
System.out.println("Pressed!");
}
});
Is there a way to say that all non-implemented methods are automatically empty or something instead of putting them into the code?