ajout mineur

This commit is contained in:
Daouadi Amir 2023-04-18 15:13:06 +02:00
parent 044f100611
commit 2851c4497f
12 changed files with 16 additions and 24 deletions

BIN
src/Accueil.class Normal file

Binary file not shown.

BIN
src/Boutons.class Normal file

Binary file not shown.

BIN
src/Fenetre.class Normal file

Binary file not shown.

BIN
src/GridPanel$1.class Normal file

Binary file not shown.

BIN
src/GridPanel$2.class Normal file

Binary file not shown.

BIN
src/GridPanel$3.class Normal file

Binary file not shown.

BIN
src/GridPanel$4.class Normal file

Binary file not shown.

BIN
src/GridPanel$5.class Normal file

Binary file not shown.

BIN
src/GridPanel$6.class Normal file

Binary file not shown.

BIN
src/GridPanel.class Normal file

Binary file not shown.

View File

@ -4,8 +4,6 @@ import java.util.Random;
import java.awt.event.*; import java.awt.event.*;
public class GridPanel extends JPanel { public class GridPanel extends JPanel {
private static final long serialVersionUID = 1L;
private int gridSize = 10; private int gridSize = 10;
private int cellSize = 50; private int cellSize = 50;
private Color[][] gridColors; private Color[][] gridColors;
@ -30,6 +28,7 @@ public class GridPanel extends JPanel {
} }
} }
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int row = e.getY() / cellSize; int row = e.getY() / cellSize;
@ -52,7 +51,7 @@ public class GridPanel extends JPanel {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
editMode = !editMode; editMode = !editMode;
if (editMode) { if (editMode) {
editButton.setText("Mode Dessin"); editButton.setText("Mode Auditeur");
placeJoueurButton.setEnabled(false); placeJoueurButton.setEnabled(false);
placeTButton.setEnabled(false); placeTButton.setEnabled(false);
} else { } else {
@ -64,16 +63,16 @@ public class GridPanel extends JPanel {
}); });
add(editButton); add(editButton);
placeJoueurButton = new JButton("Placer Joueur"); placeJoueurButton = new JButton("Placer Thésée");
placeJoueurButton.addActionListener(new ActionListener() { placeJoueurButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
placeJoueurMode = !placeJoueurMode; placeJoueurMode = !placeJoueurMode;
if (placeJoueurMode) { if (placeJoueurMode) {
placeJoueurButton.setText("Mode Dessin"); placeJoueurButton.setText("Mode Auditeur");
editButton.setEnabled(false); editButton.setEnabled(false);
placeTButton.setEnabled(false); placeTButton.setEnabled(false);
} else { } else {
placeJoueurButton.setText("Placer Joueur"); placeJoueurButton.setText("Placer Thésée");
editButton.setEnabled(true); editButton.setEnabled(true);
placeTButton.setEnabled(true); placeTButton.setEnabled(true);
} }
@ -81,16 +80,16 @@ public class GridPanel extends JPanel {
}); });
add(placeJoueurButton); add(placeJoueurButton);
placeTButton = new JButton("Placer Lettre T"); placeTButton = new JButton("Placer Sortie");
placeTButton.addActionListener(new ActionListener() { placeTButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
placeTMode = !placeTMode; placeTMode = !placeTMode;
if (placeTMode) { if (placeTMode) {
placeTButton.setText("Mode Dessin"); placeTButton.setText("Mode Auditeur");
editButton.setEnabled(false); editButton.setEnabled(false);
placeJoueurButton.setEnabled(false); placeJoueurButton.setEnabled(false);
} else { } else {
placeTButton.setText("Placer Lettre T"); placeTButton.setText("Placer Sortie");
editButton.setEnabled(true); editButton.setEnabled(true);
placeJoueurButton.setEnabled(true); placeJoueurButton.setEnabled(true);
} }
@ -99,6 +98,7 @@ public class GridPanel extends JPanel {
add(placeTButton); add(placeTButton);
} }
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
@ -144,13 +144,5 @@ public static void main(String[] args) {
frame.getContentPane().add(gridPanel.getComponents()[0], BorderLayout.NORTH); frame.getContentPane().add(gridPanel.getComponents()[0], BorderLayout.NORTH);
frame.pack(); frame.pack();
frame.setVisible(true); frame.setVisible(true);
Timer timer = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gridPanel.repaint();
}
});
timer.start();
} }
} }