Tests modele et vue mélangé

This commit is contained in:
Justine Yannis
2022-10-13 11:01:22 +02:00
parent 8cfc88de43
commit a6148c3ff9
5 changed files with 155 additions and 0 deletions

23
premierTests/Pion.java Normal file
View File

@@ -0,0 +1,23 @@
import java.awt.*;
import javax.swing.*;
public class Pion extends JComponent{
public Pion() {
this.setMinimumSize(new Dimension(80,80));
this.setMaximumSize(new Dimension(150,150));
this.setPreferredSize(new Dimension(120,120));
this.setBackground(Color.WHITE);
}
@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);
}
}