Bonjour,
j'ai écris ce prg en exécutant,il y a qu'un seul bouton
avec "click to know the answer"
veuillez m'aidez pour résoudre ce problem svp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <html> <head> <title>Questions and Answers</title> </head> <body> <applet code=Question.class width=400 height=100> <param name=question value="What is Inheritance?"> <param name=answer value="Getting the properties of one class into another"> </applet> </body> </html>
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 import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Question extends Applet implements ActionListener { String theQuestion; String theAnswer=""; Button reveal=new Button("Click to know the answer"); public void init() { theQuestion=getParameter("ques"); add(reveal); reveal.addActionListener(this); } public void pain(Graphics g) { g.setColor(Color.black); g.drawString(theQuestion, 10,50); g.setColor(Color.red); g.drawString(theAnswer, 10, 70); } public void actionPerformed(ActionEvent e) { theQuestion=getParameter("question"); theAnswer=getParameter("answer"); repaint(); } }
Partager