import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class EventTest2 extends JFrame {
    private JButton button;
    private JLabel label;
    int counter = 0;

    class MyListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            counter++;
            label.setText("현재의 카운터값: " + counter);
        }
    }

    public EventTest2() {
        setSize(400, 150);
        setTitle("이벤트 예제");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setLayout(new FlowLayout());
        button = new JButton("증가");
        label = new JLabel("현재의 카운터값: " + counter);

        button.addActionListener(new MyListener());
        add(label, "Center");
        add(button, "East");
        setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> new EventTest2());
    }
}