0

So I run an applet as usual when in the bottom left corner where it says "Executing applet in appletviewer" stays there and appletviewer never opens up. When I right click on the class, "Run Applet" is in red, if that's important at all. I've uninstalled everything Java related on my computer and re-installed JDK 7 multiple times as well as BlueJ and I still get the result of appletviewer not popping up. The applet class I keep trying is straight from my textbook's website so I'm guessing there's nothing wrong with the code. The applet works fine with everyone else's computers at my school. So what can I do to make appletviewer work?

Here's the code to the class:

import javax.swing.JApplet;
import java.awt.*;

public class Snowman extends JApplet
{
public void paint (Graphics page)
{
  final int MID = 150;
  final int TOP = 50;

  setBackground (Color.cyan);

  page.setColor (Color.blue);
  page.fillRect (0, 175, 300, 50);  // ground

  page.setColor (Color.yellow);
  page.fillOval (-40, -40, 80, 80);  // sun

  page.setColor (Color.white);
  page.fillOval (MID-20, TOP, 40, 40);      // head
  page.fillOval (MID-35, TOP+35, 70, 50);   // upper torso
  page.fillOval (MID-50, TOP+80, 100, 60);  // lower torso

  page.setColor (Color.black);
  page.fillOval (MID-10, TOP+10, 5, 5);   // left eye
  page.fillOval (MID+5, TOP+10, 5, 5);    // right eye

  page.drawArc (MID-10, TOP+20, 20, 10, 190, 160);   // smile

  page.drawLine (MID-25, TOP+60, MID-50, TOP+40);  // left arm
  page.drawLine (MID+25, TOP+60, MID+55, TOP+60);  // right arm

  page.drawLine (MID-20, TOP+5, MID+20, TOP+5);  // brim of hat
  page.fillRect (MID-15, TOP-20, 30, 25);        // top of hat
}
}
Roman C
  • 49,761
  • 33
  • 66
  • 176

1 Answers1

1

Make sure that you import the applet class before running. That might have something to do with your problem. import java.applet.; import java.awt.;