TP06 - TP07 début
This commit is contained in:
BIN
APL2.1/TP06/Gris/Gris.class
Normal file
BIN
APL2.1/TP06/Gris/Gris.class
Normal file
Binary file not shown.
7
APL2.1/TP06/Gris/Gris.java
Normal file
7
APL2.1/TP06/Gris/Gris.java
Normal file
@@ -0,0 +1,7 @@
|
||||
import java.awt.Color;
|
||||
|
||||
public class Gris extends Color {
|
||||
public Gris(int l) {
|
||||
super(l, l, l);
|
||||
}
|
||||
}
|
||||
BIN
APL2.1/TP06/Gris/TestGris.class
Normal file
BIN
APL2.1/TP06/Gris/TestGris.class
Normal file
Binary file not shown.
24
APL2.1/TP06/Gris/TestGris.java
Normal file
24
APL2.1/TP06/Gris/TestGris.java
Normal file
@@ -0,0 +1,24 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class TestGris {
|
||||
public static void main(String[] args) {
|
||||
int size = Integer.parseInt(args[0]);
|
||||
|
||||
JFrame fenetre = new JFrame("Damier");
|
||||
fenetre.setSize(size * 50, size * 50);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
GridLayout grid = new GridLayout(size, size);
|
||||
fenetre.setLayout(grid);
|
||||
|
||||
for (int i = 0; i < size * size; i++) {
|
||||
JPanel panel = new JPanel();
|
||||
if (i % 2 == 0) panel.setBackground(new Gris(150));
|
||||
else panel.setBackground(Color.WHITE);
|
||||
fenetre.add(panel);
|
||||
}
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user