Code:
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class threeRiddles extends Applet implements ActionListener
{
public Font nameFont;
public Font buttonFont;
public Font buttonFont2;
public Image pic;
public Button BNQ;
public Font normalFont;
public String answerToRiddle;
public String riddlel1;
public String riddlel2;
public String riddlel3;
public String riddlel4;
public String riddlel5;
public String riddlel6;
public Label riddleLA1;
public Label riddleLA2;
public Label riddleLA3;
public Label riddleLA4;
public Label riddleLA5;
public Label riddleLA6;
public TextField answerRiddle;
public void init()
{
setLayout(null);
setSize(500,680);
setBackground (Color.blue);
normalFont = new Font ("Times New Roman", Font.BOLD, 14);
buttonFont = new Font ("Dialog", Font.BOLD, 12);
buttonFont2 = new Font ("Dialog", Font.BOLD, 12);
nameFont = new Font ("SansSerif", Font.BOLD, 28);
pic = getImage(getCodeBase(), "albert14.gif");
riddlel1 = "This thing all things devours;";
riddlel2 = "Birds, beasts, trees, flowers;";
riddlel3 = "Gnaws irons, bites steel;";
riddlel4 = "Grinds hard stones to meal;";
riddlel5 = "Slays king, ruins town,";
riddlel6 = "And beats high mountain down.";
answerRiddle = new TextField();
answerRiddle.setBounds(135,180,75,20);
add(answerRiddle);
BNQ = new Button("Quit");
BNQ.setBounds(135,210,100,36);
BNQ.setFont(buttonFont);
BNQ.setBackground(Color.yellow);
BNQ.addActionListener(this);
add(BNQ);
riddleLA1 = new Label(riddlel1);
riddleLA1.setBounds(20,70,240,20);
riddleLA1.setFont(normalFont);
add(riddleLA1);
riddleLA2 = new Label(riddlel2);
riddleLA2.setBounds(20,85,240,20);
riddleLA2.setFont(normalFont);
add(riddleLA2);
riddleLA3 = new Label(riddlel3);
riddleLA3.setBounds(20,100,240,20);
riddleLA3.setFont(normalFont);
add(riddleLA3);
riddleLA4 = new Label(riddlel4);
riddleLA4.setBounds(20,115,240,20);
riddleLA4.setFont(normalFont);
add(riddleLA4);
riddleLA5 = new Label(riddlel5);
riddleLA5.setBounds(20,130,240,20);
riddleLA5.setFont(normalFont);
add(riddleLA5);
riddleLA6 = new Label(riddlel6);
riddleLA6.setBounds(20,145,240,20);
riddleLA6.setFont(normalFont);
add(riddleLA6);
}
public void paint(Graphics g)
{
g.setColor (Color.red);
g.setFont (nameFont);
g.drawString("Java Riddle Game", 20, 40);
g.drawString("Clue...", 90, 270);
g.drawImage(pic, 90, 275, this);
}
public void actionPerformed(ActionEvent event)
{
String command = event.getActionCommand();
String answerToRiddle = answerRiddle.getText();
If (command.equals("time"));
{
}
}
}
Thnx for any help.
Bookmarks