BUT2/DEV/DEV2.1/TP06_Dessin/Q3_Acceuil/Accueil.java

41 lines
1.1 KiB
Java
Raw Permalink Normal View History

2023-10-23 13:23:36 +02:00
import javax.swing.JComponent;
import java.awt.*;
import javax.swing.*;
public class Accueil extends JComponent {
private Image acc;
public Accueil() {
super();
this.acc = Toolkit.getDefaultToolkit().getImage("login.jpg");
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()) {
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.drawImage(this.acc,0,0,this);
}
public static void main(String[] args) {
JFrame fenetre = new JFrame();
Accueil imag = new Accueil();
JTextField champlog = new JTextField();
JTextField champmdp = new JTextField();
fenetre.setLayout(null);
fenetre.setSize(290,220);
fenetre.setLocation(0,0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
imag.setLocation(0,0);
imag.setSize(278,183);
champlog.setSize(160,20);
champlog.setLocation(102,92);
champmdp.setSize(160,20);
champmdp.setLocation(102,134);
fenetre.add(imag);
fenetre.add(champlog);
fenetre.add(champmdp);
fenetre.setVisible(true);
}
}