Ajout des travaux effectuer
This commit is contained in:
35
23DEV1.1/TPS2/TP01/Evènements/Evènement2/Playlist.java
Normal file
35
23DEV1.1/TPS2/TP01/Evènements/Evènement2/Playlist.java
Normal file
@@ -0,0 +1,35 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
|
||||
public class Playlist extends JComponent implements MouseWheelListener
|
||||
{
|
||||
int n = 0;
|
||||
int x = 70;
|
||||
protected void paintComponent(Graphics pinceau)
|
||||
{
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.drawRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
for(int i = 0 ; i <10 ; i++)
|
||||
{
|
||||
secondPinceau.setColor(Color.GRAY);
|
||||
secondPinceau.fillOval(x+10, 130, 70, 70);
|
||||
x = x+90;
|
||||
}
|
||||
for(int i = 0 ; i <n ; i++)
|
||||
{
|
||||
secondPinceau.setColor(Color.YELLOW);
|
||||
secondPinceau.fillOval(x+10, 130, 70, 70);
|
||||
x = x+90;
|
||||
}
|
||||
}
|
||||
public Playlist(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
18
23DEV1.1/TPS2/TP01/Evènements/Evènement2/TestPlaylist.java
Normal file
18
23DEV1.1/TPS2/TP01/Evènements/Evènement2/TestPlaylist.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class TestPlaylist
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(1000, 300);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setBackground(Color.GREY);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
Playlist p = new Playlist();
|
||||
|
||||
p.add();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
23DEV1.1/TPS2/TP01/Evènements/Evènement2/TestVolume.class
Normal file
BIN
23DEV1.1/TPS2/TP01/Evènements/Evènement2/TestVolume.class
Normal file
Binary file not shown.
15
23DEV1.1/TPS2/TP01/Evènements/Evènement2/TestVolume.java
Normal file
15
23DEV1.1/TPS2/TP01/Evènements/Evènement2/TestVolume.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class TestVolume
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(1000, 300);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.add(new Volume());
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
23DEV1.1/TPS2/TP01/Evènements/Evènement2/Volume.class
Normal file
BIN
23DEV1.1/TPS2/TP01/Evènements/Evènement2/Volume.class
Normal file
Binary file not shown.
44
23DEV1.1/TPS2/TP01/Evènements/Evènement2/Volume.java
Normal file
44
23DEV1.1/TPS2/TP01/Evènements/Evènement2/Volume.java
Normal file
@@ -0,0 +1,44 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
|
||||
public class Volume extends JComponent implements MouseWheelListener
|
||||
{
|
||||
int x = 0;
|
||||
int nbrClic = 0;
|
||||
protected void paintComponent(Graphics pinceau)
|
||||
{
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
secondPinceau.setColor(Color.DARK_GRAY);
|
||||
secondPinceau.fillRect(0,0,this.getWidth(), this.getHeight());
|
||||
for(int i = 0 ; i < 10 ; i++)
|
||||
{
|
||||
secondPinceau.setColor(Color.GRAY);
|
||||
secondPinceau.fillOval(x, 50, 70, 70);
|
||||
x = x+60;
|
||||
}
|
||||
for(int i = 0 ; i < this.nbrClic ; i++)
|
||||
{
|
||||
secondPinceau.setColor(Color.YELLOW);
|
||||
secondPinceau.fillOval(x, 50, 70, 70);
|
||||
x = x+60;
|
||||
}
|
||||
}
|
||||
public void mouseWheelMoved(MouseWheelEvent evenement)
|
||||
{
|
||||
this.nbrClic = evenement.getWheelRotation();
|
||||
this.repaint();
|
||||
if(this.nbrClic>=10){
|
||||
nbrClic++;
|
||||
}
|
||||
if(this.nbrClic<=0){
|
||||
nbrClic--;
|
||||
}
|
||||
}
|
||||
public Volume(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user