Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++

JAVA


PHP
SQL
Alice

ListenerExample


Description

Run it
Download jar file (Right click)

ListenerExampleApplet.java
ListenerExamplePanel.java
SomeListener.java

SomeListener.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
 * A very simple listener that just prints a message when it is informed of an event.
 * 
 * @author cusack
 *
 */
public class SomeListener implements ActionListener {
	 /**
	  * The actionPerfomed method required by the ActionListener interface.
	  */
	 public void actionPerformed(ActionEvent e) {
		 JOptionPane.showMessageDialog(null,
				 "Somebody pressed the button",
				 "Button Pressed",
				 JOptionPane.INFORMATION_MESSAGE);
	 }
}