Basic Swing Program with Dialog Boxes

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;

public class Adding_Dialog2 extends Applet implements ActionListener
{

JLabel score;
int num1, num2; //random numbers
int points = 0;

public void init ()
{

JLabel instruction = new JLabel ("Adding Game");
instruction.setFont (new Font ("Arial", Font.BOLD, 18));
instruction.setForeground (Color.blue);

JLabel question = new JLabel ("Press new question to get a question. ");
score = new JLabel ("Score: 000");
JButton newquestion = new JButton ("Get a new question");
newquestion.setActionCommand ("new_add");
newquestion.addActionListener (this);

add (instruction);
add (question);
add (newquestion);
add (score);

}


public void actionPerformed (ActionEvent e)
{

if (e.getActionCommand ().equals ("new_add"))
{
num1 = ((int) (Math.random () * 5)) + 1;
num2 = ((int) (Math.random () * 5)) + 1;
String quest = ("Answer this question: " + num1 + " + " + num2 + " = ");
String input = JOptionPane.showInputDialog (quest);
int ans = Integer.parseInt (input);
if (ans == (num1 + num2))
{
JOptionPane.showMessageDialog (null, (num1 + num2) + " is correct! You got it right!", "CORRECT!", JOptionPane.INFORMATION_MESSAGE);
points++;
score.setText ("Score: " + points);
num1 = 0;
}
else
{
JOptionPane.showMessageDialog (null, (num1 + num2) + " is the correct answer, not " + input, "WRONG", JOptionPane.ERROR_MESSAGE);
score.setText ("Score: " + points);
num1 = 0;
}

}

}

}