Files
DEV/DEV2.1/TP06/Accueil.java
Simoes Lukas 080e0022b8 Fin du TP06
2025-02-16 23:19:06 +01:00

55 lines
1.8 KiB
Java

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);
}
}