This commit is contained in:
2023-04-04 14:03:16 +02:00
parent 7021891e9c
commit e32d4de827
111 changed files with 1928 additions and 6 deletions

View File

@@ -0,0 +1,33 @@
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
public class Cercles extends JComponent {
private int i;
public Cercles(){
super();
}
public void getNombre(int a){
this.i=a;
this.repaint();
}
@Override
public void paintComponent(Graphics pinceau){
Graphics pinpin=pinceau.create();
if(this.isOpaque()){
pinpin.setColor(this.getBackground());
pinpin.fillRect(0, 0, this.getWidth(), this.getHeight());
}
for (int j = 0; j < this.i; j++) {
pinpin.setColor(Color.YELLOW);
pinpin.fillOval(j*30, this.getHeight()/2, 20, 20);
}
for (int j=this.i; j < 10; j++) {
pinpin.setColor(Color.GRAY);
pinpin.fillOval(j*30, this.getHeight()/2, 20, 20);
}
}
}

View File

@@ -0,0 +1,17 @@
import javax.swing.JFrame;
public class Volume {
public static void main(String[] args) {
JFrame fenetre=new JFrame();
fenetre.setSize(500,100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Cercles test=new Cercles();
VolumeAct stiti=new VolumeAct(test);
fenetre.addMouseWheelListener(stiti);
fenetre.add(test);
fenetre.setVisible(true);
}
}

View File

@@ -0,0 +1,25 @@
import java.awt.event.*;
public class VolumeAct implements MouseWheelListener {
private int a;
private Cercles ce;
public VolumeAct(Cercles chat){
super();
this.a=0;
this.ce=chat;
}
public void mouseWheelMoved(MouseWheelEvent e){
int i;
i=e.getWheelRotation();
if(i<0 && this.a<10){
this.a++;
ce.getNombre(this.a);
}
if(i>0 && this.a>0){
this.a--;
ce.getNombre(this.a);
}
}
}