Head First Java book-this() question
Hi, I have been having the hardest time understanding exactly what the "this" statement does. Supposedly it is a reference to the "current object". But I don't know what that means. Please if anyone can explain. Thank you. Derek
Here is the code example.
Code:
public class SimpleGui1B implements ActionListener {
JButton button;
public static void main (String[] args) {
SimpleGui1B gui = new SimpleGui1B();
gui.go();
}
public void go() {
JFrame frame = new JFrame();
button = new JButton("click me");
button.addActionListenter([B][COLOR="Red"]this[/COLOR][/B]);
////more gui relevant code goes here
}
public void actionPerformed(ActionEvent event) {
button.setText("I've been clicked");
}
}