Fin du TP06
This commit is contained in:
parent
dd8ce34656
commit
080e0022b8
BIN
DEV2.1/TP06/Accueil.class
Normal file
BIN
DEV2.1/TP06/Accueil.class
Normal file
Binary file not shown.
55
DEV2.1/TP06/Accueil.java
Normal file
55
DEV2.1/TP06/Accueil.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Accueil extends JComponent {
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics pinceau) {
|
||||||
|
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||||
|
Graphics secondPinceau = pinceau.create();
|
||||||
|
// obligatoire : si le composant n'est pas censé être transparent
|
||||||
|
if (this.isOpaque()) {
|
||||||
|
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||||
|
secondPinceau.setColor(this.getBackground());
|
||||||
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logo
|
||||||
|
Image logo = Toolkit.getDefaultToolkit().getImage("logo.png");
|
||||||
|
secondPinceau.drawImage(logo, 10, 30,this);
|
||||||
|
|
||||||
|
// Texte Logo
|
||||||
|
Font police = new Font("URW Gothic", Font.BOLD,30);
|
||||||
|
secondPinceau.setFont(police);
|
||||||
|
secondPinceau.setColor(Color.WHITE);
|
||||||
|
secondPinceau.drawString("IUT",35,40);
|
||||||
|
|
||||||
|
// Texte titre
|
||||||
|
police = new Font("URW Gothic", Font.BOLD, 23);
|
||||||
|
secondPinceau.setFont(police);
|
||||||
|
secondPinceau.drawString("Département",112,35);
|
||||||
|
secondPinceau.drawString("informatique",118,60);
|
||||||
|
|
||||||
|
// Texte login/pswd
|
||||||
|
secondPinceau.drawString("login",64,100);
|
||||||
|
secondPinceau.drawString("password", 15, 130);
|
||||||
|
|
||||||
|
// Les TextFields sont directement ajoutés à la fenêtre
|
||||||
|
JTextField login = new JTextField();
|
||||||
|
JTextField password = new JTextField();
|
||||||
|
login.setBounds(130,82,120,20);
|
||||||
|
password.setBounds(130,112,120,20);
|
||||||
|
this.add(login);
|
||||||
|
this.add(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
Accueil menu = new Accueil();
|
||||||
|
fenetre.setSize(278,183);
|
||||||
|
fenetre.setLocation(100,100);
|
||||||
|
fenetre.getContentPane().setBackground(new Color(156,120,200));
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.add(menu);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
@ -3,13 +3,6 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class Formes extends JComponent {
|
public class Formes extends JComponent {
|
||||||
|
|
||||||
private String typeComposant;
|
|
||||||
|
|
||||||
public Formes(String typeComposant) {
|
|
||||||
super();
|
|
||||||
this.typeComposant = typeComposant;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics pinceau) {
|
protected void paintComponent(Graphics pinceau) {
|
||||||
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||||
@ -21,22 +14,30 @@ public class Formes extends JComponent {
|
|||||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.typeComposant == "Carre") {
|
// Carré
|
||||||
secondPinceau.setColor(new Color(51,153,255));
|
secondPinceau.setColor(new Color(51,153,255));
|
||||||
secondPinceau.fillRect(0, 0, 50, 50);
|
secondPinceau.fillRect(100, 100, 50, 50);
|
||||||
secondPinceau.setColor(Color.BLUE);
|
secondPinceau.setColor(Color.BLUE);
|
||||||
secondPinceau.drawRect(0,0,50,50);
|
secondPinceau.drawRect(100,100,50,50);
|
||||||
}
|
|
||||||
|
|
||||||
if (this.typeComposant == "Disque") {
|
// Disque
|
||||||
// TODO
|
secondPinceau.setColor(Color.GREEN);
|
||||||
}
|
secondPinceau.drawOval(175,100,25,25);
|
||||||
|
|
||||||
|
// Texte
|
||||||
|
secondPinceau.setColor(new Color(80, 00, 80));
|
||||||
|
Font police = new Font("Arial", Font.BOLD, 24);
|
||||||
|
secondPinceau.setFont(police);
|
||||||
|
secondPinceau.drawString(">o<", 100, 200);
|
||||||
|
|
||||||
|
// Image
|
||||||
|
Image logo = Toolkit.getDefaultToolkit().getImage("logo.png");
|
||||||
|
secondPinceau.drawImage(logo, 175, 175, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JFrame fenetre = new JFrame();
|
JFrame fenetre = new JFrame();
|
||||||
Formes test = new Formes("Carre");
|
Formes test = new Formes();
|
||||||
// on configure la fenetre
|
// on configure la fenetre
|
||||||
fenetre.setSize(500, 500);
|
fenetre.setSize(500, 500);
|
||||||
fenetre.setLocation(0, 0);
|
fenetre.setLocation(0, 0);
|
||||||
|
BIN
DEV2.1/TP06/GFG.class
Normal file
BIN
DEV2.1/TP06/GFG.class
Normal file
Binary file not shown.
12
DEV2.1/TP06/Main.java
Normal file
12
DEV2.1/TP06/Main.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
Sautoir test = new Sautoir();
|
||||||
|
// on configure la fenetre
|
||||||
|
fenetre.setSize(500, 500);
|
||||||
|
fenetre.setLocation(0, 0);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.add(test);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP06/Sautoir.class
Normal file
BIN
DEV2.1/TP06/Sautoir.class
Normal file
Binary file not shown.
38
DEV2.1/TP06/Sautoir.java
Normal file
38
DEV2.1/TP06/Sautoir.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Sautoir extends JComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics pinceau) {
|
||||||
|
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||||
|
Graphics secondPinceau = pinceau.create();
|
||||||
|
// obligatoire : si le composant n'est pas censé être transparent
|
||||||
|
if (this.isOpaque()) {
|
||||||
|
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||||
|
secondPinceau.setColor(this.getBackground());
|
||||||
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] coord_x = {0, this.getWidth(), 0, this.getWidth()};
|
||||||
|
int[] coord_y = {0, 0, this.getHeight(), this.getHeight()};
|
||||||
|
Polygon p = new Polygon(coord_x, coord_y, 4);
|
||||||
|
secondPinceau.setColor(Color.CYAN);
|
||||||
|
secondPinceau.fillPolygon(p);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
GridLayout layout = new GridLayout(5, 5);
|
||||||
|
// on configure la fenetre
|
||||||
|
fenetre.setSize(250, 250);
|
||||||
|
fenetre.setLocation(0, 0);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.setLayout(layout);
|
||||||
|
for (int i = 0; i != 25; i++) {
|
||||||
|
fenetre.add(new Sautoir());
|
||||||
|
}
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP06/login.jpg
Normal file
BIN
DEV2.1/TP06/login.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 30 KiB |
BIN
DEV2.1/TP06/logo.png
Normal file
BIN
DEV2.1/TP06/logo.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.9 KiB |
Loading…
x
Reference in New Issue
Block a user