ajout du menu

This commit is contained in:
martins 2022-10-13 12:12:16 +02:00
parent c23300e474
commit cb8f9cf290
12 changed files with 178 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -0,0 +1,30 @@
package fr.iutfbleau.projetAgile.Controlers;
import java.awt.event.MouseListener;
import java.awt.event.*;
import javax.swing.JFrame;
public class obeservateur_menu_souris implements MouseListener{
private boutons_menu bout;
private JFrame fenetre;
public obeservateur_menu_souris(boutons_menu boutons, JFrame fenetre0){
this.bout=boutons;
this.fenetre=fenetre0;
}
public void mouseClicked(MouseEvent evenement){
if(this.bout.getPath()=="puissance4.png"){
this.fenetre.dispose();
}
} // un bouton cliqué
public void mouseEntered(MouseEvent evenement){
this.bout.setSurvol(true);
} // debut du survol
public void mouseExited(MouseEvent evenement){
this.bout.setSurvol(false);
} // fin du survol
public void mousePressed(MouseEvent evenement){
this.bout.setSurvol(false);
} // un bouton appuyé
public void mouseReleased(MouseEvent evenement){
this.bout.setSurvol(true);
} // un bouton relâché
}

View File

@ -0,0 +1,42 @@
package fr.iutfbleau.projetAgile.View;
import java.lang.*;
import javax.swing.JComponent;
import java.awt.*;
public class boutons_menu extends JComponent{
private String path;
private boolean survol;
private Image img;
public boutons_menu(String path0){
super();
this.path=path0;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
this.img = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/"+this.path));
this.survol=false;
}
public void setSurvol(boolean bol){
this.survol=bol;
this.repaint();
}
public String getPath(){
return this.path;
}
@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());
}
// maintenant on dessine ce que l'on veut
if(this.survol==false){
secondPinceau.drawImage(this.img, 5, 5, this.getWidth()-5, this.getHeight()-5, this);
}else{
secondPinceau.drawImage(this.img, 0, 0, this.getWidth(), this.getHeight(), this);
}
}
}

View File

@ -0,0 +1,106 @@
package fr.iutfbleau.projetAgile.View;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import fr.iutfbleau.projetAgile.Controlers.*;
public class menu extends JFrame{
public menu(){
super();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(0,0);
this.setSize(1280,720);
(this.getContentPane()).setBackground(new Color(31,31,31));
GridBagLayout gbl=new GridBagLayout();
this.setLayout(gbl);
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridx=0;
gbc.gridy=0;
gbc.gridwidth=3;
gbc.gridheight=1;
gbc.fill=GridBagConstraints.BOTH;
gbc.anchor=GridBagConstraints.CENTER;
gbc.weightx=2;
gbc.weighty=0;
gbc.insets=new Insets(0,10,0,10);
JLabel titre=new JLabel("ARGILE GAMES");
titre.setHorizontalAlignment(JLabel.CENTER);
titre.setForeground(new Color(255,255,255));
titre.setBackground(new Color(55,55,55));
titre.setFont(new Font("Serif" ,Font.BOLD, 50));
titre.setPreferredSize(new Dimension(400,200));
this.add(titre, gbc);
boutons_menu puissance_4=new boutons_menu("puissance4.png");
boutons_menu echecs=new boutons_menu("echecs.png");
boutons_menu dames=new boutons_menu("dames.png");
boutons_menu demineur=new boutons_menu("demineur.png");
boutons_menu taquin=new boutons_menu("taquin.png");
boutons_menu morpion=new boutons_menu("morpion.png");
boutons_menu CoD=new boutons_menu("CoD.png");
boutons_menu minecraft=new boutons_menu("minecraft.png");
boutons_menu puzzle=new boutons_menu("puzzle.png");
puissance_4.addMouseListener(new obeservateur_menu_souris(puissance_4, this));
echecs.addMouseListener(new obeservateur_menu_souris(echecs, this));
dames.addMouseListener(new obeservateur_menu_souris(dames, this));
demineur.addMouseListener(new obeservateur_menu_souris(demineur, this));
taquin.addMouseListener(new obeservateur_menu_souris(taquin, this));
morpion.addMouseListener(new obeservateur_menu_souris(morpion, this));
CoD.addMouseListener(new obeservateur_menu_souris(CoD, this));
minecraft.addMouseListener(new obeservateur_menu_souris(minecraft, this));
puzzle.addMouseListener(new obeservateur_menu_souris(puzzle, this));
this.add(puissance_4, menu.GridBagConstraintsRetour(0, 1));
this.add(echecs, menu.GridBagConstraintsRetour(1, 1));
this.add(dames, menu.GridBagConstraintsRetour(2, 1));
this.add(demineur, menu.GridBagConstraintsRetour(0, 2));
this.add(taquin, menu.GridBagConstraintsRetour(1, 2));
this.add(morpion, menu.GridBagConstraintsRetour(2, 2));
this.add(CoD, menu.GridBagConstraintsRetour(0, 3));
this.add(minecraft, menu.GridBagConstraintsRetour(1, 3));
this.add(puzzle, menu.GridBagConstraintsRetour(2, 3));
this.setVisible(true);
}
public static GridBagConstraints GridBagConstraintsRetour(int collonne, int ligne){
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridx=collonne;
gbc.gridy=ligne;
gbc.gridwidth=1;
gbc.gridheight=1;
gbc.fill=GridBagConstraints.BOTH;
gbc.anchor=GridBagConstraints.CENTER;
gbc.weightx=1;
gbc.weighty=1;
Insets marge=new Insets(0,0,0,0);
if(collonne==0){
marge.set(5, 50, 5, 5);
}
if(collonne==2){
marge.set(5, 5, 5, 50);
}
if(collonne==1){
marge.set(5, 5, 5, 5);
}
if(ligne==3 && collonne==1){
marge.set(5, 5, 50, 5);
}
if(ligne==3 && collonne==0){
marge.set(5, 50, 50, 5);
}
if(ligne==3 && collonne==2){
marge.set(5, 5, 50, 50);
}
gbc.insets=marge;
return gbc;
}
}