import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class NewEvents implements ActionListener { //------------------------------------------------------------------- // main() entry point //------------------------------------------------------------------- public static void main (String[] args) { new NewEvents(); } //------------------------------------------------------------------- // NewEvents Constructor //------------------------------------------------------------------- public NewEvents() { Frame window; Button button; // create a non-subclassed AWT container and component window = new Frame("a vanilla Frame window"); button = new Button("a vanilla (1.1) Button"); // register us as interested in button's clicks button.addActionListener(this); window.setLayout(new FlowLayout()); window.add(button); window.setSize(new Dimension(300,100)); window.show(); } //------------------------------------------------------------------- // the actionPerformed() method is where the Button object notifies // us that a click has occurred. This method is the sole method we // needed to implement to honor the ActionListener interface. //------------------------------------------------------------------- public void actionPerformed (ActionEvent buttonClick) { System.out.println("Event trapping with no AWT class subclassing !"); } } // End of Class NewEvents