update
This commit is contained in:
@@ -2,20 +2,35 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class Volume extends JComponent {
|
public class Volume extends JComponent {
|
||||||
|
private int niveau = 5;
|
||||||
|
|
||||||
public Volume() {
|
public Volume() {
|
||||||
super();
|
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
|
@Override
|
||||||
protected void paintComponent(Graphics pinceau) {
|
protected void paintComponent(Graphics pinceau) {
|
||||||
Graphics secondPinceau = pinceau.create();
|
Graphics secondPinceau = pinceau.create();
|
||||||
this.setColor(this.getForeground());
|
if (this.isOpaque()){
|
||||||
|
secondPinceau.setColor(this.getBackground);
|
||||||
this.setBackground(new Color(255,30,255));
|
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
|
||||||
|
}
|
||||||
this.setColor(Color.GRAY);
|
secondPinceau.setBackground(Color.BLUE);
|
||||||
this.fillOval(10, 70, 100, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user