How does this method work?
<p>I have often come across this way of registering an action listener.</p>

<p>Though I have been using this method recently but I don't understand how's and why's of this</p>

<p>Here is one :{</p>

<pre><code>submit=new JButton("submit");
submit.addActionListener(new ActionListener(){       // line 1

  public void actionPerformed(ActionEvent ae) {
    submitActionPerformed(ae);
  }
}); //action listener added
</code></pre>

<p>}
Method that is invoked :</p>

<pre><code>public void submitActionPerformed(ActionEvent ae) {

    // body

}
</code></pre>

<p>In this method, I don't need to implement ActionListener. Why?</p>

<p>Also, please explain what the code labeled as <code>line 1</code> does.</p>

<p>Please explain the 2 snippets clearly. </p>
