diff --git a/DEV2.1/TP7:Evenements/Mainvolume.class b/DEV2.1/TP7:Evenements/Mainvolume.class new file mode 100644 index 0000000..bdb10df Binary files /dev/null and b/DEV2.1/TP7:Evenements/Mainvolume.class differ diff --git a/DEV2.1/TP7:Evenements/Mainvolume.java b/DEV2.1/TP7:Evenements/Mainvolume.java new file mode 100644 index 0000000..7f9b9dd --- /dev/null +++ b/DEV2.1/TP7:Evenements/Mainvolume.java @@ -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); + } +} \ No newline at end of file diff --git a/DEV2.1/TP7:Evenements/Volume.class b/DEV2.1/TP7:Evenements/Volume.class new file mode 100644 index 0000000..05d3eb6 Binary files /dev/null and b/DEV2.1/TP7:Evenements/Volume.class differ diff --git a/DEV2.1/TP7:Evenements/Volume.java b/DEV2.1/TP7:Evenements/Volume.java new file mode 100644 index 0000000..837be17 --- /dev/null +++ b/DEV2.1/TP7:Evenements/Volume.java @@ -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; i0){ + if(pos==0){ + } + else{ + pos--; + this.repaint(); + } + } + if (mv<0){ + if(pos==10){ + } + else{ + pos++; + this.repaint(); + } + } + } +} \ No newline at end of file