This commit is contained in:
Adrian POURCHOT 2023-03-20 17:57:20 +01:00
parent 663e795de2
commit d14f7c23c6
3 changed files with 30 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,20 @@
import javax.swing.*;
import java.awt.*;
public class Damier{
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(400, 400);
fenetre.setLocation(0, 0);
GridLayout grille = new GridLayout(5,5);
fenetre.setLayout(grille);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (int i=0; i < 25; ++i){
JPanel panel = new JPanel();
panel.setBackground(i%2 == 0 ? Color.WHITE : Color.CYAN);
fenetre.add(panel);
} fenetre.setVisible(true);
}
}

View File

@ -0,0 +1,10 @@
import javax.swing.*;
import java.awt.*;
public class Sautoir extends JComponent{
protected void paintComponent(Graphics pinceau) {
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
Graphics pinceau = pinceau.create();
pinceau.setColor(Color.CYAN);
pinceau.fillPolygon([0,0],[50,0],3);