27 Octobre
This commit is contained in:
BIN
DEV3.2/TP3/Luminance/Luminance.class
Normal file
BIN
DEV3.2/TP3/Luminance/Luminance.class
Normal file
Binary file not shown.
52
DEV3.2/TP3/Luminance/Luminance.java
Normal file
52
DEV3.2/TP3/Luminance/Luminance.java
Normal file
@@ -0,0 +1,52 @@
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Color;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Luminance extends JPanel implements MouseListener{
|
||||
|
||||
public Luminance(){
|
||||
super();
|
||||
}
|
||||
|
||||
boolean listenoncréer = true;
|
||||
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
// obligatoire : on cree un nouveau pinceau pour pouvoir le modifier plus tard
|
||||
Graphics pinceau2 = pinceau.create();
|
||||
List<Integer> paralleloliste = new ArrayList<>();
|
||||
int color;
|
||||
if (this.isOpaque()) {
|
||||
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||
pinceau2.setColor(Color.DARK_GRAY);
|
||||
pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
} if(listenoncréer){
|
||||
for (int i=0; i<30; i++){
|
||||
Random rand = new Random();
|
||||
color = rand.nextInt(256);
|
||||
paralleloliste.add(i,color);
|
||||
} listenoncréer = false;
|
||||
} for (int i=0; i<10; i++){
|
||||
int x[] = {0+(this.getWidth()/11)*i,80+(this.getWidth()/11)*i,180+(this.getWidth()/11)*i,100+(this.getWidth()/11)*i};
|
||||
int y[] = {this.getHeight()-10,10,10,this.getHeight()-10};
|
||||
pinceau2.setColor(new Color(paralleloliste.get(0+3*i),paralleloliste.get(1+3*i),paralleloliste.get(2+3*i)));
|
||||
pinceau2.fillPolygon(x,y,4);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e){
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e){
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e){
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e){
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e){
|
||||
}
|
||||
}
|
||||
BIN
DEV3.2/TP3/Luminance/MainLuminance.class
Normal file
BIN
DEV3.2/TP3/Luminance/MainLuminance.class
Normal file
Binary file not shown.
18
DEV3.2/TP3/Luminance/MainLuminance.java
Normal file
18
DEV3.2/TP3/Luminance/MainLuminance.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
public class MainLuminance{
|
||||
public static void main(String[] args) {
|
||||
|
||||
JFrame fenetre = new JFrame();
|
||||
Luminance pan = new Luminance();
|
||||
fenetre.setSize(1200, 250);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.addMouseListener(pan);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setContentPane(pan);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user