File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes button.addActionListener (this)   ???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "button.addActionListener (this)   ????" Watch "button.addActionListener (this)   ????" New topic

button.addActionListener (this) ????

Dario Romani

Joined: Oct 03, 2003
Posts: 13
Just reading through the User Interfaces that Swing - A Quick Start Guide tutorial at .
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?
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9058
Notice that

public class CelsiusConverter implements ActionListener



means that the actions for this ActionListener can be found in this class, the CelsiusConverter class.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: button.addActionListener (this) ????
It's not a secret anymore!