Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

button.addActionListener (this) ????

 
Dario Romani
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just reading through the User Interfaces that Swing - A Quick Start Guide tutorial at java.sun.com .
Early on they used an inline definition of the action listener using an anonympous inner class (see Example 2 of Turorial):

Then all of a sudden their code fragments switched to (see Example 3 and Example 4 of Tutorial):

Can someone explain what the syntax that utilizes "this" does?
Thanks.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that

public class CelsiusConverter implements ActionListener

Therefore

button.addActionListener(this);

means that the actions for this ActionListener can be found in this class, the CelsiusConverter class.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic