update
This commit is contained in:
BIN
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Barre.class
Normal file
BIN
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Barre.class
Normal file
Binary file not shown.
18
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Barre.java
Normal file
18
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Barre.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Barre{
|
||||
public static void main(String[] args) {
|
||||
|
||||
Rond test = new Rond(10);
|
||||
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(800, 800);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.add(test);
|
||||
test.addMouseWheelListener(test);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
public interface MouseWheelListener{
|
||||
void mouseWheelMoved(MouseWheelEvent evenement);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
public interface MouseWheelListener{
|
||||
void mouseWheelMoved(MouseWheelEvent evenement);
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Rond.class
Normal file
BIN
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Rond.class
Normal file
Binary file not shown.
44
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Rond.java
Normal file
44
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Rond.java
Normal file
@@ -0,0 +1,44 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
public class Rond extends JComponent implements MouseWheelListener{
|
||||
public int nbRond;
|
||||
public int valeur;
|
||||
public double tailleRond;
|
||||
|
||||
public Rond(int nbRond){
|
||||
this.nbRond = nbRond;
|
||||
this.valeur = 0;
|
||||
this.tailleRond = 0.8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
secondPinceau.setColor(new Color(0,0,0));
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
|
||||
secondPinceau.setColor(new Color(0,255,100));
|
||||
int unite = this.getWidth() / this.nbRond;
|
||||
int diametre = (int) ((double) unite * tailleRond);
|
||||
int ordonnee = (getHeight()-diametre)/2;
|
||||
for (int i=0; i<this.nbRond; i++){
|
||||
if (this.valeur <= i){
|
||||
secondPinceau.setColor(new Color(100,0,255));
|
||||
}
|
||||
secondPinceau.fillOval(i*unite+(unite-diametre)/2, ordonnee,diametre,diametre);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e){
|
||||
if (e.getWheelRotation() < 0) {
|
||||
if (this.valeur<this.nbRond){
|
||||
this.valeur++;
|
||||
}
|
||||
} else {
|
||||
if (this.valeur>0){
|
||||
this.valeur--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Rond.java~
Normal file
46
DEV/DEV2.1/TP09_Evenement2/Q1_Volume/Rond.java~
Normal file
@@ -0,0 +1,46 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
public class Rond extends JComponent implements MouseWheelListener{
|
||||
public int nbRond;
|
||||
public int valeur;
|
||||
public double tailleRond;
|
||||
|
||||
public Rond(int nbRond){
|
||||
this.nbRond = nbRond;
|
||||
this.valeur = 0;
|
||||
this.tailleRond = 0.8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
secondPinceau.setColor(new Color(0,0,0));
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
|
||||
secondPinceau.setColor(new Color(0,255,100));
|
||||
int unite = this.getWidth() / this.nbRond;
|
||||
int diametre = (int) ((double) unite * tailleRond);
|
||||
int ordonnee = (getHeight()-diametre)/2;
|
||||
for (int i=0; i<this.nbRond; i++){
|
||||
if (this.valeur <= i){
|
||||
secondPinceau.setColor(new Color(100,0,255));
|
||||
}
|
||||
secondPinceau.fillOval(i*unite+(unite-diametre)/2, ordonnee,diametre,diametre);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e){
|
||||
if (e.getWheelRotation() < 0) {
|
||||
if (this.valeur<10){
|
||||
this.valeur++;
|
||||
repaint();
|
||||
}
|
||||
} else {
|
||||
if (this.valeur>0){
|
||||
this.valeur--;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user