This commit is contained in:
Moncef STITI 2024-02-05 10:23:12 +01:00
parent 8723822304
commit 97ca073fdd
5 changed files with 81 additions and 38 deletions

View File

@ -2,31 +2,23 @@ import javax.swing.*;
import java.awt.*;
public class exo3 {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(500, 300);
fenetre.setLocation(300, 300);
JPanel panneauBouton = new JPanel();
JPanel panneauPrincipal = new JPanel();
JLabel texte = new JLabel("Aimez-vous les chiens ?");
JButton bouton1 = new JButton("Oui");
panneauBouton.add(bouton1);
JButton bouton2 = new JButton("Non");
panneauBouton.add(bouton2);
JButton bouton3 = new JButton("NSPP");
panneauBouton.add(bouton3);
panneauPrincipal.add(texte, BorderLayout.CENTER);
panneauPrincipal.add(panneauBouton, BorderLayout.SOUTH);
fenetre.add(panneauPrincipal, BorderLayout.CENTER);
fenetre.setVisible(true);
}
public static void main(String[] args) {
JFrame fenetre = new JFrame("Exo3");
fenetre.setSize(200, 200);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout flow = new FlowLayout(FlowLayout.CENTER);
fenetre.setLayout(flow);
JLabel panel = new JLabel("Aimez-vous les chiens ?");
panel.setPreferredSize(new Dimension(486, 20));
panel.setHorizontalAlignment(JLabel.CENTER);
JButton yes = new JButton("Oui");
JButton no = new JButton("Non");
JButton maybe = new JButton("NSPP");
fenetre.add(panel);
fenetre.add(yes);
fenetre.add(no);
fenetre.add(maybe);
fenetre.setVisible(true);
}
}

View File

@ -1,15 +1,66 @@
import javax.swing.*;
import java.awt.*;
public class exo4{
public static void main(String[] args){
JFrame fenetre = new JFrame();
fenetre.setSize(600,400);
fenetre.setLocation(300,300);
public class exo4 {
public static void main(String[] args) {
JFrame fenetre = new JFrame("Exo4");
fenetre.setSize(500, 500);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout gestionnaire = new GridLayout(3, 1);
fenetre.setLayout(gestionnaire);
JLabel texte1 = new JLabel("Mystral");
JLabel texte2 = new JLabel("texte2");
JLabel texte3 = new JLabel("texte3");
JLabel texte4 = new JLabel("texte4");
JLabel texte5 = new JLabel("texte5");
JLabel texte6 = new JLabel("texte6");
JLabel texte7 = new JLabel("texte7");
JLabel texte8 = new JLabel("texte8");
// Texte n°1 :
texte1.setHorizontalAlignment(JLabel.LEFT);
texte1.setVerticalAlignment(JLabel.TOP);
// Texte n°2 :
texte2.setHorizontalAlignment(JLabel.CENTER);
texte2.setVerticalAlignment(JLabel.TOP);
// Texte n°3 :
texte3.setHorizontalAlignment(JLabel.RIGHT);
texte3.setVerticalAlignment(JLabel.TOP);
// Texte n°4 :
texte4.setHorizontalAlignment(JLabel.LEFT);
texte4.setVerticalAlignment(JLabel.CENTER);
// Texte n°5 :
texte5.setHorizontalAlignment(JLabel.RIGHT);
texte5.setVerticalAlignment(JLabel.CENTER);
// Texte n°6 :
texte6.setHorizontalAlignment(JLabel.LEFT);
texte6.setVerticalAlignment(JLabel.BOTTOM);
// Texte n°7 :
texte7.setHorizontalAlignment(JLabel.CENTER);
texte7.setVerticalAlignment(JLabel.BOTTOM);
// Texte n°8 :
texte8.setHorizontalAlignment(JLabel.RIGHT);
texte8.setVerticalAlignment(JLabel.BOTTOM);
fenetre.add(texte1);
fenetre.add(texte2);
fenetre.add(texte3);
fenetre.add(texte4);
fenetre.add(texte5);
fenetre.add(texte6);
fenetre.add(texte7);
fenetre.add(texte8);
GridLayout gestionnaire = new GridLayout(3,0);
fenetre.setVisible(true);
}
fenetre.setVisible(true);
}
}