wow le tp là
This commit is contained in:
BIN
DEV3.1/TP03/01_Boutons/Fenetre.class
Normal file
BIN
DEV3.1/TP03/01_Boutons/Fenetre.class
Normal file
Binary file not shown.
64
DEV3.1/TP03/01_Boutons/Fenetre.java
Normal file
64
DEV3.1/TP03/01_Boutons/Fenetre.java
Normal file
@@ -0,0 +1,64 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(300, 200);
|
||||
this.setLocation(100, 100);
|
||||
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
|
||||
this.setLayout(layout);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
JButton b1 = new JButton("1");
|
||||
JButton b2 = new JButton("2");
|
||||
JButton b3 = new JButton("3");
|
||||
JButton b4 = new JButton("4");
|
||||
JButton b5 = new JButton("5");
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridheight = 1;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
|
||||
this.add(b1, gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 2;
|
||||
|
||||
this.add(b2, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 2;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridheight = 1;
|
||||
|
||||
this.add(b3, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 2;
|
||||
|
||||
this.add(b4, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 1;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 1;
|
||||
gbc.weightx = 0.0;
|
||||
gbc.weighty = 0.0;
|
||||
|
||||
this.add(b5, gbc);
|
||||
this.addWindowListener(new WindowControler(this));
|
||||
}
|
||||
|
||||
}
|
BIN
DEV3.1/TP03/01_Boutons/Main.class
Normal file
BIN
DEV3.1/TP03/01_Boutons/Main.class
Normal file
Binary file not shown.
6
DEV3.1/TP03/01_Boutons/Main.java
Normal file
6
DEV3.1/TP03/01_Boutons/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP03/01_Boutons/WindowControler.class
Normal file
BIN
DEV3.1/TP03/01_Boutons/WindowControler.class
Normal file
Binary file not shown.
50
DEV3.1/TP03/01_Boutons/WindowControler.java
Normal file
50
DEV3.1/TP03/01_Boutons/WindowControler.java
Normal file
@@ -0,0 +1,50 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
public class WindowControler implements WindowListener {
|
||||
|
||||
private Fenetre fenetre;
|
||||
|
||||
public WindowControler(Fenetre fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowClosed(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowClosing(WindowEvent evenement) {
|
||||
int resultat = JOptionPane.showConfirmDialog(fenetre, null);
|
||||
if (resultat == JOptionPane.YES_OPTION) {
|
||||
fenetre.dispose();
|
||||
}
|
||||
} // avant fermeture
|
||||
|
||||
|
||||
public void windowDeactivated(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowDeiconified(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowIconified(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowOpened(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user