Files
DEV/DEV2.1/TP03/TP03_reponses.txt

72 lines
1.3 KiB
Plaintext
Raw Normal View History

2025-01-30 16:07:12 +01:00
1.
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(500,500);
fenetre.setLocation(100,100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout layout = new GridLayout(4,1);
fenetre.setLayout(layout);
fenetre.add(new JRadioButton("Gryffondor"));
fenetre.add(new JRadioButton("Serpentard"));
fenetre.add(new JRadioButton("Serdaigle"));
fenetre.add(new JRadioButton("Poufsouffle"));
fenetre.setVisible(true);
}
}
2.
2025-02-06 14:32:11 +01:00
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
int a = Integer.parseInt(args[0]);
fenetre.setSize(500,500);
fenetre.setLocation(100,100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout layout = new GridLayout(a,a);
fenetre.setLayout(layout);
Color color_1 = Color.WHITE;
Color color_2 = Color.CYAN;
for (int j = 0; j < a; j++) {
Color temp = color_1;
color_1 = color_2;
color_2 = temp;
for(int i = 0; i < a; i++) {
JPanel panneau = new JPanel();
if (i%2 == 0) {
panneau.setBackground(color_1);
}
else {
panneau.setBackground(color_2);
}
fenetre.add(panneau);
}
}
fenetre.setVisible(true);
}
}
3.