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

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


    public EventTest4() {
        this.setSize(400, 150);
        this.setTitle("이벤트 예제");

        JPanel panel = new JPanel();
        button = new JButton("증가");
        label = new JLabel("현재의 카운터값: " + counter);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                counter++;
                label.setText("현재의 카운터값: " + counter);
            }
        });
        panel.add(label);
        panel.add(button);
        add(panel);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> new EventTest4());
    }
}