Update DEV.2.1/CM-blanc/CM-1/Main.java

This commit is contained in:
2025-04-17 23:15:27 +02:00
parent c51de060f8
commit 2cce2ade4f

View File

@@ -7,4 +7,74 @@ public class Main {
fenetre.setVisible(true);
}
}
/**
*
*/
public class Main {
public static void main(String[] args) {
FenetreDebut fenetredebut = new FenetreDebut();
fenetredebut.setVisible(true);
}
}
/**
* La classe <code>PaintFenetreDebut</code> est utilisée pour dessiner et faire apparaître l'image de menu sur
* la fenêtre de début de jeu.
*
* @version 1.2
* @author Emmanuel SRIVASTAVA-TIAMZON
*/
import javax.swing.*;
import java.awt.*;
public class PaintFenetreDebut extends JComponent {
private Image MenuDebut;
public PaintFenetreDebut() {
this.MenuDebut = Toolkit.getDefaultToolkit().getImage("../image/MenuDebut.jpg");
}
@Override
public 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.MenuDebut, this.getWidth(), this.getHeight(), this);
}
}
import javax.swing.*;
import java.awt.*;
public class FenetreDebut extends JFrame {
public FenetreDebut() {
super("SameGame");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(765, 510);
this.setLocation(this.getWidth()/2 - 100 ,this.getHeight()/2 - 100);
JPanel imagePanel = new JPanel();
imagePanel.setLayout(new GridLayout(1,1));
PaintFenetreDebut paintfenetredebut = new PaintFenetreDebut();
this.add(paintfenetredebut);
}
}