20 Mars
This commit is contained in:
parent
663e795de2
commit
d14f7c23c6
BIN
DEV2.1/TP5:MiseEnPageEtDessin/Damier.class
Normal file
BIN
DEV2.1/TP5:MiseEnPageEtDessin/Damier.class
Normal file
Binary file not shown.
20
DEV2.1/TP5:MiseEnPageEtDessin/Damier.java
Normal file
20
DEV2.1/TP5:MiseEnPageEtDessin/Damier.java
Normal 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);
|
||||
}
|
||||
}
|
10
DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java
Normal file
10
DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java
Normal 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);
|
Loading…
Reference in New Issue
Block a user