Files
DEV/DEV3.2/TP03/01_Luminance/Fenetre.java
Simoes Lukas ca833fec2f tp3
2025-10-16 12:33:25 +02:00

39 lines
901 B
Java

import java.awt.*;
import javax.swing.*;
import java.util.Random;
import java.util.List;
import java.util.ArrayList;
public class Fenetre extends JFrame {
private JParallelogramme p;
public Fenetre() {
this.setSize(300, 100);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout(FlowLayout.CENTER));
List<Color> listeCouleurs = new ArrayList<Color>();
int r, g, b;
Random aleatoire = new Random();
for (int i = 0; i != 10; i++) {
r = Math.abs(aleatoire.nextInt()) % 255;
g = Math.abs(aleatoire.nextInt()) % 255;
b = Math.abs(aleatoire.nextInt()) % 255;
listeCouleurs.add(new Color(r, g, b));
}
this.p = new JParallelogramme(listeCouleurs);
p.addMouseListener(new ControleurParallelogramme(listeCouleurs, this));
this.add(p);
}
public JParallelogramme getP() {
return this.p;
}
}