MainClass.java 899 Bytes
package tp2.evenements;


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

public class MainClass {
    public static void main(String[] args) {
        JLabel label = new JLabel("0");
        label.setFont(new Font("SansSerif", Font.PLAIN, 25));

        JPanel topPanel = new JPanel();
        topPanel.add(label);


        JButton incbutt = new JButton("incrémenter");
        incbutt.addActionListener(new ReponseAuClic(label));

        JPanel botPanel = new JPanel();
        botPanel.add(incbutt);


        JFrame win = new JFrame();
        win.setLocationRelativeTo(null);
        BoxLayout layout = new BoxLayout(win.getContentPane(), BoxLayout.Y_AXIS);
        win.setLayout(layout);

        win.add(topPanel);
        win.add(botPanel);

        win.setResizable(false);
        win.pack();

        win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        win.setVisible(true);
    }
}