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

public class Butons {

    public static void main(String[] args) {
        JFrame f = new JFrame();
        GridBagLayout gbl = new GridBagLayout();
        f.setLayout(gbl);

        GridBagConstraints c = new GridBagConstraints();

        JButton b1 = new JButton("1");
        c.gridx = 1;
        c.gridy = 1;
        c.gridwidth = 2;
        c.gridheight = 1;
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        c.insets = new Insets(0, 0, 0, 0);
        c.weightx = 1f;
        c.weighty = 1f;
        f.add(b1, c);

        JButton b2 = new JButton("2");
        c.gridx = 3;
        c.gridy = 1;
        c.gridwidth = 1;
        c.gridheight = 2;
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        c.insets = new Insets(0, 0, 0, 0);
        c.weightx = 1f;
        c.weighty = 1f;
        f.add(b2, c);

        JButton b3 = new JButton("3");
        c.gridx = 2;
        c.gridy = 3;
        c.gridwidth = 2;
        c.gridheight = 1;
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        c.insets = new Insets(0, 0, 0, 0);
        c.weightx = 1f;
        c.weighty = 1f;
        f.add(b3, c);

        JButton b4 = new JButton("4");
        c.gridx = 1;
        c.gridy = 2;
        c.gridwidth = 1;
        c.gridheight = 2;
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        c.insets = new Insets(0, 0, 0, 0);
        c.weightx = 1f;
        c.weighty = 1f;
        f.add(b4, c);

        JButton b5 = new JButton("5");
        b5.setPreferredSize(new Dimension(75, 75));
        c.gridx = 2;
        c.gridy = 2;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        c.insets = new Insets(0, 0, 0, 0);
        c.weightx = 0f;
        c.weighty = 0f;
        f.add(b5, c);

        f.addWindowListener(new WindowListener() {

            @Override
            public void windowActivated(WindowEvent e) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void windowClosed(WindowEvent e) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void windowClosing(WindowEvent e) {
                int confirm = JOptionPane.showConfirmDialog(f, "Voulez-vous vraiment fermer la fenêtre ?");
                if (confirm == 0) {
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                }  else {
                    f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                }
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void windowDeiconified(WindowEvent e) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void windowIconified(WindowEvent e) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void windowOpened(WindowEvent e) {
                // TODO Auto-generated method stub
                
            }
            
        });

        f.setSize(225, 225);
        f.setVisible(true);
    }
}