someMethod(new Xxxx () { /* class body. */ });
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
public class MainClass {
public static void main(String[] argv) {
JButton theButton = new JButton();
theButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("The action has occurred");
}
});
}
}
|