How can I overwrite 'Applet started.' in java applet before I do anything else. What I'm trying to do is when I run an applet I want to show a question in the status bar and then try to answer it to JTextField but I don't know how to do that. Below is the code:
public class Multiplication extends JApplet implements ActionListener { JLabel showAnswer; JTextField answer; int usersAnswer, product, value1, value2; public void init() { Container c=getContentPane(); c.setLayout(new FlowLayout());
showAnswer=new JLabel("Type in the answer: "); answer=new JTextField(10); answer.addActionListener(this); c.add(showAnswer); c.add(answer); showStatus(""); }
public void start() { showStatusBar(); }
public void actionPerformed(ActionEvent e) { multiplication(); }
public void multiplication() { usersAnswer=Integer.parseInt(answer.getText());
if (usersAnswer==product) { showStatus("Very good!"); } if (usersAnswer!=product) { showStatus("No.Please try again."); } }
public void showStatusBar() { value1=0+(int) (Math.random()*9); value2=0+(int) (Math.random()*9); showStatus("How much is "+value1+" times "+value2+"?"); product=value1*value2; } }