Files
DEV/DEV.2.1/TP/TP9-Event..suite/1./Volume.java

36 lines
812 B
Java
Raw Normal View History

2025-03-10 17:31:32 +01:00
import javax.swing.*;
import java.awt.*;
public class Volume extends JComponent {
2025-03-16 11:33:42 +01:00
private int niveau = 5;
2025-03-10 17:31:32 +01:00
public Volume() {
super();
}
2025-03-16 11:33:42 +01:00
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;
}
2025-03-10 17:31:32 +01:00
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
2025-03-16 11:33:42 +01:00
if (this.isOpaque()){
secondPinceau.setColor(this.getBackground);
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
}
secondPinceau.setBackground(Color.BLUE);
2025-03-10 17:31:32 +01:00
}
}