Java:applet viewer

Résolu/Fermé
domxaline - 18 nov. 2012 à 20:44
 domxaline - 18 nov. 2012 à 22:39
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
<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>

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();
  }
}


A voir également:

2 réponses

KX Messages postés 16733 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 31 janvier 2024 3 015
Modifié par KX le 18/11/2012 à 20:50
C'est public void paint(Graphics g), avec un t !

Et si ton paramètre s'appelle "question" tu ne peux pas faire getParameter("ques");La confiance n'exclut pas le contrôle
0
merci beaucoup j'ai corrigé mon erreur
0