fin tp3
This commit is contained in:
39
DEV3.2/TP03/02_Chaine/Fenetre.java
Normal file
39
DEV3.2/TP03/02_Chaine/Fenetre.java
Normal file
@@ -0,0 +1,39 @@
|
||||
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));
|
||||
|
||||
CouleurList<Color> listeCouleurs = new CouleurList<>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user