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