fin des tp
This commit is contained in:
66
DEV3.1/mise_en_page/Boutons.java
Normal file
66
DEV3.1/mise_en_page/Boutons.java
Normal file
@@ -0,0 +1,66 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
|
||||
public class Boutons implements WindowListener{
|
||||
@Override
|
||||
public void windowClosing(WindowEvent evenement){
|
||||
int confirmed=JOptionPane(null,"Voulez-vous fermer l'application ?","Confirmation de fermeture",JOptionPane.YES_NO_OPTION);
|
||||
if (confirmed==JOptionPane.YES_OPTION){
|
||||
evenement.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
fenetre.setLayout(new GridBagLayout());
|
||||
c.fill=GridBagConstraints.BOTH;
|
||||
JButton etiquette = new JButton("1");
|
||||
c.gridx=0;
|
||||
c.gridy=0;
|
||||
c.gridwidth=2;
|
||||
c.gridheight=1;
|
||||
c.weightx=1;
|
||||
c.weighty=1;
|
||||
fenetre.add(etiquette,c);
|
||||
JButton etiquette1 = new JButton("2");
|
||||
c.gridx=2;
|
||||
c.gridy=0;
|
||||
c.gridwidth=1;
|
||||
c.gridheight=2;
|
||||
c.weightx=1;
|
||||
c.weighty=1;
|
||||
fenetre.add(etiquette1,c);
|
||||
JButton etiquette2 = new JButton("3");
|
||||
c.gridx=1;
|
||||
c.gridy=2;
|
||||
c.gridwidth=2;
|
||||
c.gridheight=1;
|
||||
c.weightx=1;
|
||||
c.weighty=1;
|
||||
fenetre.add(etiquette2,c);
|
||||
JButton etiquette3 = new JButton("4");
|
||||
c.gridx=0;
|
||||
c.gridy=1;
|
||||
c.gridwidth=1;
|
||||
c.gridheight=2;
|
||||
c.weightx=1;
|
||||
c.weighty=1;
|
||||
fenetre.add(etiquette3,c);
|
||||
JButton etiquette4 = new JButton("5");
|
||||
c.gridx=1;
|
||||
c.gridy=1;
|
||||
c.gridwidth=1;
|
||||
c.gridheight=1;
|
||||
c.weightx=0;
|
||||
c.weighty=0;
|
||||
fenetre.add(etiquette4,c);
|
||||
fenetre.setVisible(true);
|
||||
fenetre.addMouseListener(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user