import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Esemeny extends JFrame implements WindowListener, ActionListener { JTextField edit; JButton gomb; private int szamlalo = 0; public static void main(String[] args) { esemeny ablak = new esemeny("Az első ablakom"); ablak.setSize(350,100); ablak.setVisible(true); } public Esemeny(String title) { super(title); setLayout(new FlowLayout()); edit = new JTextField(20); gomb = new JButton("Kattints ide"); add(gomb); add(edit); addWindowListener(this); gomb.addActionListener(this); } public void actionPerformed(ActionEvent e) { szamlalo++; edit.setText("A gomb le lett nyomva " + szamlalo + " -szer"); } public void windowClosing(WindowEvent e) { dispose(); System.exit(0); } public void windowOpened(WindowEvent e) {} public void windowActivated(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} }