ajout mineur
This commit is contained in:
parent
044f100611
commit
2851c4497f
BIN
src/Accueil.class
Normal file
BIN
src/Accueil.class
Normal file
Binary file not shown.
BIN
src/Boutons.class
Normal file
BIN
src/Boutons.class
Normal file
Binary file not shown.
@ -87,4 +87,4 @@ public class Boutons extends JPanel {
|
|||||||
public JButton getImporterGrille() {
|
public JButton getImporterGrille() {
|
||||||
return importerGrille;
|
return importerGrille;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/Fenetre.class
Normal file
BIN
src/Fenetre.class
Normal file
Binary file not shown.
BIN
src/GridPanel$1.class
Normal file
BIN
src/GridPanel$1.class
Normal file
Binary file not shown.
BIN
src/GridPanel$2.class
Normal file
BIN
src/GridPanel$2.class
Normal file
Binary file not shown.
BIN
src/GridPanel$3.class
Normal file
BIN
src/GridPanel$3.class
Normal file
Binary file not shown.
BIN
src/GridPanel$4.class
Normal file
BIN
src/GridPanel$4.class
Normal file
Binary file not shown.
BIN
src/GridPanel$5.class
Normal file
BIN
src/GridPanel$5.class
Normal file
Binary file not shown.
BIN
src/GridPanel$6.class
Normal file
BIN
src/GridPanel$6.class
Normal file
Binary file not shown.
BIN
src/GridPanel.class
Normal file
BIN
src/GridPanel.class
Normal file
Binary file not shown.
@ -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;
|
||||||
@ -21,7 +19,7 @@ public class GridPanel extends JPanel {
|
|||||||
public GridPanel() {
|
public GridPanel() {
|
||||||
setPreferredSize(new Dimension(gridSize * cellSize, gridSize * cellSize));
|
setPreferredSize(new Dimension(gridSize * cellSize, gridSize * cellSize));
|
||||||
setBackground(Color.WHITE);
|
setBackground(Color.WHITE);
|
||||||
|
|
||||||
gridColors = new Color[gridSize][gridSize];
|
gridColors = new Color[gridSize][gridSize];
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
for (int i = 0; i < gridSize; i++) {
|
for (int i = 0; i < gridSize; i++) {
|
||||||
@ -29,7 +27,8 @@ public class GridPanel extends JPanel {
|
|||||||
gridColors[i][j] = rand.nextBoolean() ? Color.BLACK : Color.WHITE;
|
gridColors[i][j] = rand.nextBoolean() ? Color.BLACK : Color.WHITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@ -46,13 +45,13 @@ public class GridPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editButton = new JButton("Enlever/Ajouter Murs");
|
editButton = new JButton("Enlever/Ajouter Murs");
|
||||||
editButton.addActionListener(new ActionListener() {
|
editButton.addActionListener(new ActionListener() {
|
||||||
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 {
|
||||||
@ -63,41 +62,42 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user