-1

I wrote a JApplet program in Java.

Now when I Run the program it tells me that the class wasn't found in project.

Here is the code I wrote:

package assignment1q6.pkg1;

import javax.swing.JApplet;
import java.awt.Graphics;
public class Assignment1Q61 extends JApplet 
{
    public void paint(Graphics canvas) 
    {
        canvas.drawArc(150, 160, 100, 100, 270, 180);
        canvas.drawOval(250, 175, 70, 70);
        canvas.drawArc(235, 75, 100, 100, 180, 180);
        canvas.drawArc(320, 160, 100, 100, 90, 180);
        canvas.drawArc(235, 245, 100, 100, 0, 180);
        canvas.fillOval(265, 190, 40, 40);
    }
}

I added more code. Still when I run it, it says the same thing.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Evert Van Eeden
  • 17
  • 1
  • 1
  • 6
  • How and where are you running it? – Kiki Mar 27 '15 at 08:12
  • 2
    Applets don't run in the same sense as other Java programs do, they are suppose to be loaded by a browser (or the applet viewer), so you generally can't "run" them. Also, you've violated the paint chain, you should be calling `super.paint(canvas)` before doing any custom painting – MadProgrammer Mar 27 '15 at 08:13
  • [This is how Applets runs](http://www.cs.colostate.edu/helpdocs/JavaInDOS.html) !!! – Neeraj Jain Mar 27 '15 at 08:15
  • Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). – Andrew Thompson Mar 27 '15 at 08:42
  • I'm running it on NetBeans IDE – Evert Van Eeden Mar 27 '15 at 08:53
  • Tip: Add @Kiki (or whoever, the `@` is important) to notify the person of a new comment. – Andrew Thompson Mar 27 '15 at 09:01
  • 1
    *"I added more code. Still when I run it, it says the same thing."* Programming 'by magic' never works.. – Andrew Thompson Mar 27 '15 at 10:09

1 Answers1

2

To run applet in netbeans you just rigth click on applet file and select Run File. The applet will start in Applet viewer. enter image description here

Kiki
  • 2,243
  • 5
  • 30
  • 43