Ajout des exo 2 et 3 du TP4
This commit is contained in:
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO1/exo1.class
Normal file
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO1/exo1.class
Normal file
Binary file not shown.
42
BUT1/DEV2.1/TP3-MiseEnPage/EXO1/exo1.java
Normal file
42
BUT1/DEV2.1/TP3-MiseEnPage/EXO1/exo1.java
Normal file
@@ -0,0 +1,42 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class exo1 {
|
||||
public static void main(String[] args) {
|
||||
// un objet pour servir de fenetre
|
||||
JFrame fenetre = new JFrame();
|
||||
Dimension tailleMin = new Dimension(500,400);
|
||||
Dimension tailleMax = new Dimension(1200,400);
|
||||
Dimension taillePref = new Dimension(500, 400);
|
||||
// on configure la fenetre
|
||||
fenetre.setSize(700, 400);
|
||||
fenetre.setMinimumSize(tailleMin);
|
||||
fenetre.setMaximumSize(tailleMax);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setPreferredSize(taillePref);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
// On crée une zone de texte
|
||||
JRadioButton boutonRadio1 = new JRadioButton("Gryffondor");
|
||||
JRadioButton boutonRadio2 = new JRadioButton("Serdaigle");
|
||||
JRadioButton boutonRadio3 = new JRadioButton("Serpentard");
|
||||
JRadioButton boutonRadio4 = new JRadioButton("Poufsouffle");
|
||||
|
||||
ButtonGroup Groupe = new ButtonGroup();
|
||||
Groupe.add(boutonRadio1);
|
||||
Groupe.add(boutonRadio2);
|
||||
Groupe.add(boutonRadio3);
|
||||
Groupe.add(boutonRadio4);
|
||||
|
||||
// on ajoute le composant dans la fenetre, au milieu
|
||||
GridLayout gestionnaire = new GridLayout(4,4);
|
||||
fenetre.setLayout(gestionnaire);
|
||||
fenetre.add(boutonRadio1);
|
||||
fenetre.add(boutonRadio2);
|
||||
fenetre.add(boutonRadio3);
|
||||
fenetre.add(boutonRadio4);
|
||||
|
||||
// et on montre le resultat
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO2/exo2.class
Normal file
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO2/exo2.class
Normal file
Binary file not shown.
35
BUT1/DEV2.1/TP3-MiseEnPage/EXO2/exo2.java
Normal file
35
BUT1/DEV2.1/TP3-MiseEnPage/EXO2/exo2.java
Normal file
@@ -0,0 +1,35 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class exo2{
|
||||
public static void main(String[] args){
|
||||
// Création d'une fenêtre + configuration
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 500);
|
||||
|
||||
// Conversion de la taille donnée en argument en INT
|
||||
int nombre = Integer.parseInt(args[0]);
|
||||
|
||||
GridLayout gestionnaire = new GridLayout(nombre,nombre);
|
||||
JPanel[] bouton = new JPanel[nombre*nombre];
|
||||
|
||||
for (int i = 0; i < nombre * nombre; i++) {
|
||||
bouton[i] = new JPanel();
|
||||
|
||||
int ligne = i / nombre;
|
||||
int colonne = i % nombre;
|
||||
|
||||
if ((ligne + colonne) % 2 == 0) {
|
||||
bouton[i].setBackground(Color.WHITE);
|
||||
} else {
|
||||
bouton[i].setBackground(new Color(51,249,255));
|
||||
}
|
||||
|
||||
fenetre.add(bouton[i]);
|
||||
}
|
||||
|
||||
// Affichage de la fenêtre
|
||||
fenetre.setLayout(gestionnaire);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO3/exo3.class
Normal file
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO3/exo3.class
Normal file
Binary file not shown.
40
BUT1/DEV2.1/TP3-MiseEnPage/EXO3/exo3.java
Normal file
40
BUT1/DEV2.1/TP3-MiseEnPage/EXO3/exo3.java
Normal file
@@ -0,0 +1,40 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class exo3 {
|
||||
public static void main(String[] args) {
|
||||
// Création de la fenêtre + configuration
|
||||
JFrame fenetre = new JFrame("Exo3");
|
||||
fenetre.setSize(200, 200);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
// Création du grid layout + ajout à la fenêtre
|
||||
GridLayout grid = new GridLayout(2,1);
|
||||
fenetre.setLayout(grid);
|
||||
|
||||
// Création d'un panneau avec la question + configuration du panneau
|
||||
JLabel texte = new JLabel("Aimez-vous les chiens ?");
|
||||
texte.setPreferredSize(new Dimension(486, 20));
|
||||
texte.setHorizontalAlignment(JLabel.CENTER);
|
||||
|
||||
// Création d'un FlowLayout + ajout à la fenêtre
|
||||
FlowLayout gestionnaire = new FlowLayout(FlowLayout.CENTER);
|
||||
|
||||
// Création des boutons + ajouts à la fenêtre
|
||||
JButton yes = new JButton("Oui");
|
||||
JButton no = new JButton("Non");
|
||||
JButton maybe = new JButton("NSPP");
|
||||
|
||||
JPanel panneau = new JPanel();
|
||||
panneau.add(yes);
|
||||
panneau.add(no);
|
||||
panneau.add(maybe);
|
||||
|
||||
fenetre.add(texte);
|
||||
fenetre.add(panneau);
|
||||
|
||||
// On rend la fenêtre visible
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO4/exo4.class
Normal file
BIN
BUT1/DEV2.1/TP3-MiseEnPage/EXO4/exo4.class
Normal file
Binary file not shown.
76
BUT1/DEV2.1/TP3-MiseEnPage/EXO4/exo4.java
Normal file
76
BUT1/DEV2.1/TP3-MiseEnPage/EXO4/exo4.java
Normal file
@@ -0,0 +1,76 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
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, 3);
|
||||
fenetre.setLayout(gestionnaire);
|
||||
|
||||
JLabel texte1 = new JLabel("Mystral");
|
||||
JLabel texte2 = new JLabel("Tramontane");
|
||||
JLabel texte3 = new JLabel("Grec");
|
||||
JLabel texte4 = new JLabel("Ponant");
|
||||
JLabel texte5 = new JLabel("Levant");
|
||||
JLabel texte6 = new JLabel("Libeccio");
|
||||
JLabel texte7 = new JLabel("Marin");
|
||||
JLabel texte8 = new JLabel("Sirocco");
|
||||
JLabel texte9 = new JLabel("Texte");
|
||||
|
||||
JPanel panneau1 = new JPanel();
|
||||
JPanel panneau2 = new JPanel();
|
||||
JPanel panneau3 = new JPanel();
|
||||
|
||||
// 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.CENTER);
|
||||
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);
|
||||
|
||||
// Texte n°9 :
|
||||
texte9.setHorizontalAlignment(JLabel.CENTER);
|
||||
texte9.setVerticalAlignment(JLabel.CENTER);
|
||||
|
||||
fenetre.add(texte1);
|
||||
fenetre.add(texte2);
|
||||
fenetre.add(texte3);
|
||||
fenetre.add(texte4);
|
||||
fenetre.add(texte5);
|
||||
fenetre.add(texte6);
|
||||
fenetre.add(texte7);
|
||||
fenetre.add(texte8);
|
||||
fenetre.add(texte9);
|
||||
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user