j'ai besoin vos aides
en exécutant mon prg,rien se produit,je crois que j'ai un pb avec AdjustementEvent
quelqu'un peut m'aider svp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 import java.awt.*; import java.applet.Applet; import java.awt.event.*; //import java.lang.Object; public class CelsiusValue extends Applet implements AdjustmentListener { private Scrollbar bar; private int old,newtemp=0; private int fahr=32; public void init() { bar=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,100); bar.addAdjustmentListener(this); setLayout(new BorderLayout()); add("North",bar); } public void paint(Graphics g) { g.drawString("Celsius="+newtemp, 30, 50); g.drawString("Fahrenheit="+fahr,30,70); } public void adjustementValueChanged(AdjustementEvent e) { newtemp=bar.getValue(); if(newtemp!=old) { fahr=newtemp*9/5+32; old=newtemp; } repaint(); } }
Partager