From 701f3383c2ce52cd5b11ebd022879db1d418a020 Mon Sep 17 00:00:00 2001 From: Emmanuel Srivastava Date: Sun, 16 Mar 2025 11:33:42 +0100 Subject: [PATCH] update --- DEV.2.1/TP/TP9-Event..suite/1./Volume.java | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/DEV.2.1/TP/TP9-Event..suite/1./Volume.java b/DEV.2.1/TP/TP9-Event..suite/1./Volume.java index 5c26c68..d7e39d0 100644 --- a/DEV.2.1/TP/TP9-Event..suite/1./Volume.java +++ b/DEV.2.1/TP/TP9-Event..suite/1./Volume.java @@ -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); } } \ No newline at end of file