This commit is contained in:
Emmanuel Srivastava
2025-03-16 11:33:42 +01:00
parent d6a390d876
commit 701f3383c2

View File

@@ -2,20 +2,35 @@ import javax.swing.*;
import java.awt.*;
public class Volume extends JComponent {
private int niveau = 5;
public Volume() {
super();
}
public setNiveau(int newNiveau) {
if (newNiveau < 0) {
this.niveau = 0;
} else if (newNiveau > 10) {
this.niveau = 10;
} else {
this.niveau = newNiveau;
}
repaint();
}
public int getNiveau() {
return this.niveau;
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
this.setColor(this.getForeground());
this.setBackground(new Color(255,30,255));
this.setColor(Color.GRAY);
this.fillOval(10, 70, 100, 100);
if (this.isOpaque()){
secondPinceau.setColor(this.getBackground);
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
}
secondPinceau.setBackground(Color.BLUE);
}
}