7 Juin
This commit is contained in:
parent
b2e4a82bd9
commit
2da42fcdcc
BIN
DEV2.1/TP7:Evenements/Mainvolume.class
Normal file
BIN
DEV2.1/TP7:Evenements/Mainvolume.class
Normal file
Binary file not shown.
17
DEV2.1/TP7:Evenements/Mainvolume.java
Normal file
17
DEV2.1/TP7:Evenements/Mainvolume.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class Mainvolume{
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
Volume pan = new Volume();
|
||||||
|
fenetre.setSize(1000, 150);
|
||||||
|
fenetre.setLocation(0, 0);
|
||||||
|
fenetre.addMouseWheelListener(pan);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.setContentPane(pan);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP7:Evenements/Volume.class
Normal file
BIN
DEV2.1/TP7:Evenements/Volume.class
Normal file
Binary file not shown.
48
DEV2.1/TP7:Evenements/Volume.java
Normal file
48
DEV2.1/TP7:Evenements/Volume.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class Volume extends JPanel implements MouseWheelListener{
|
||||||
|
|
||||||
|
int pos=0;
|
||||||
|
|
||||||
|
public Volume(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void paintComponent(Graphics pinceau) {
|
||||||
|
// obligatoire : on cree un nouveau pinceau pour pouvoir le modifier plus tard
|
||||||
|
Graphics pinceau2 = pinceau.create();
|
||||||
|
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());
|
||||||
|
} for(int i=0; i<pos; i++){
|
||||||
|
pinceau2.setColor(Color.ORANGE);
|
||||||
|
pinceau2.fillOval((this.getWidth()/33)+(this.getWidth()/31)*3*i, this.getHeight()/4, (this.getWidth()/31)*2, this.getHeight()/2);
|
||||||
|
} for(int j=pos; j<10; j++){
|
||||||
|
pinceau2.setColor(Color.GRAY);
|
||||||
|
pinceau2.fillOval((this.getWidth()/33)+(this.getWidth()/31)*3*j, this.getHeight()/4, (this.getWidth()/31)*2, this.getHeight()/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent e){
|
||||||
|
int mv = e.getWheelRotation();
|
||||||
|
if (mv>0){
|
||||||
|
if(pos==0){
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pos--;
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mv<0){
|
||||||
|
if(pos==10){
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pos++;
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user