Changement couleur

This commit is contained in:
Justine Yannis 2022-10-13 10:57:43 +02:00
parent 2199452cba
commit 8cfc88de43
3 changed files with 3 additions and 11 deletions

View File

@ -5,6 +5,7 @@ import java.awt.Color;
public class Utils {
public final static Color PLAYER_ONE_COLOR = Color.RED;
public final static Color PLAYER_TWO_COLOR = Color.YELLOW;
public final static Color EMPTY_COLOR = new Color(42,42,42);
public final static int PLAYER_ONE = 0;
public final static int PLAYER_TWO = 1;
public static int PAWN_MARGIN = 10;

View File

@ -29,6 +29,7 @@ public class Grille extends JPanel {
/*
* On peut remplacer GridBagLayout par un GridLayout
*/
this.setBackground(new Color(31,31,31));
GridBagLayout gbl = new GridBagLayout();
this.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
@ -61,10 +62,4 @@ public class Grille extends JPanel {
this.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
}
@Override
protected void paintComponent(Graphics g) {
Graphics g2 = g.create();
g2.setColor(Color.BLUE);
g2.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 3 * Utils.PAWN_MARGIN, 3 * Utils.PAWN_MARGIN);
}
}

View File

@ -22,16 +22,12 @@ public class Pion extends JComponent{
this.setMinimumSize(new Dimension(80,80));
this.setMaximumSize(new Dimension(150,150));
this.setPreferredSize(new Dimension(120,120));
this.setBackground(Color.WHITE);
this.setBackground(Utils.EMPTY_COLOR);
}
@Override
protected void paintComponent(Graphics g) {
Graphics g2 = g.create();
//g2.setColor(Color.BLUE);
//g2.fillRect(0, 0, this.getWidth(), this.getHeight());
g2.setColor(Color.GRAY);
g2.fillOval((int) (Utils.PAWN_MARGIN * 1.2),(int) (Utils.PAWN_MARGIN * 1.1) , this.getWidth() - 2 * Utils.PAWN_MARGIN, this.getHeight() - 2 * Utils.PAWN_MARGIN + 2);
g2.setColor(this.getBackground());
g2.fillOval(Utils.PAWN_MARGIN, Utils.PAWN_MARGIN, this.getWidth() - 2 * Utils.PAWN_MARGIN, this.getHeight() - 2 * Utils.PAWN_MARGIN);
}