POLITECHNIKA RZESZOWSKA - Wydział Elektrotechniki i Informatyki
import javax.swing. import java.awt.event.*;
public class AnonymousClassListenerTest extends JFrame { AnonymousClassListenerTest(String title)( setTitle(title); setBounds(100, 100, 300, 150);
JButton button = new JButton("Close window !"); ActionListener listener = new ActionLi s te ner () ( public void actionPerformed(ActionEvent e) ( System.exit(0);
button.addActionListener(listener);
JPanel p = new JPanelO; p.add(button); getContentPane().add(p); setVisible(true);
)
public static void main(String[] args) (
new AnonymousClassListenerTest("My Window");