update
This commit is contained in:
34
DEV.2.1/TP/TP3-MiseenPage/Damier.java
Normal file
34
DEV.2.1/TP/TP3-MiseenPage/Damier.java
Normal file
@@ -0,0 +1,34 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Damier {
|
||||
public static void main(String[] args){
|
||||
JFrame frame = new JFrame("Damier");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
int xpan = Integer.parseInt(args[0]);
|
||||
int ypan;
|
||||
ypan = xpan;
|
||||
|
||||
GridLayout gestionnaire = new GridLayout(xpan, ypan);
|
||||
frame.setLayout(gestionnaire);
|
||||
|
||||
for(int i = 0; i < xpan*ypan; i++){
|
||||
if(i % 2 == 0){
|
||||
JPanel panneau = new JPanel();
|
||||
panneau.setBackground(Color.WHITE);
|
||||
frame.add(panneau);
|
||||
}else{
|
||||
JPanel panneau = new JPanel();
|
||||
panneau.setBackground(Color.CYAN);
|
||||
frame.add(panneau);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
frame.setSize(500,500);
|
||||
frame.setLocation(500,250);
|
||||
frame.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user