Normally, I use this
in constructors only.
I understand that it is used to identify the parameter variable (by using this.something
), if i
In Swing its fairly common to write a class that implements ActionListener
and add the current instance (ie 'this') as an ActionListener for components.
public class MyDialog extends JDialog implements ActionListener
{
public MyDialog()
{
JButton myButton = new JButton("Hello");
myButton.addActionListener(this);
}
public void actionPerformed(ActionEvent evt)
{
System.out.println("Hurdy Gurdy!");
}
}