I need to change this program that I made to an applet. I can't seem to get java to paint. Do i need to use a content pane? I tried using a content pane which was commented out. I must be missing something.

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

public class RepArt extends JApplet
{
    private Tree Tree1 = new Tree(0, 150);
    private Tree Tree2 = new Tree(100, 100);
    private Tree Tree3 = new Tree(225, 175);
    private Tree Tree4 = new Tree(275, 120);
    private Cloud Cloud1 = new Cloud(-25, 0);
    private Cloud Cloud2 = new Cloud(0, 0);
    private Cloud Cloud3 = new Cloud(205, -20);
    private Cloud Cloud4 = new Cloud(100, 75);
    private Cloud Cloud5 = new Cloud(-50, 100);
    private Cloud Cloud6 = new Cloud(225, -20);
    private CrazyFruit CrazyFruit1 = new CrazyFruit(50, 50);
    private CrazyFruit CrazyFruit2 = new CrazyFruit (150,0);
    private CrazyFruit CrazyFruit3 = new CrazyFruit (275,75);
    private CrazyFruit CrazyFruit4 = new CrazyFruit (325, 20);

    // Custom colors
    Color brown = new Color(100, 50,0);
    Color lightblue = new Color(0, 0, 255);
    Color waterblue = new Color(20, 0, 255);
    Color grey = new Color(0, 100, 0);


    //public void init()
    //{
    //Container c = getContentPane();
    //}

    public void paintComponent(Graphics g)
    {
        g.setColor(Color.white);
        g.fillRect(0, 0, 400, 400);
        Tree1.paintTree(g);
        Tree2.paintTree(g);
        Tree3.paintTree(g);
        Tree4.paintTree(g);
        Cloud1.paintCloud(g);
        Cloud2.paintCloud(g);
        Cloud3.paintCloud(g);
        Cloud4.paintCloud(g);
        Cloud5.paintCloud(g);
        Cloud6.paintCloud(g);
        CrazyFruit1.paintCrazyFruit(g);
        CrazyFruit2.paintCrazyFruit(g);
        CrazyFruit3.paintCrazyFruit(g);
        CrazyFruit4.paintCrazyFruit(g);
    }

    public class Tree
        {
             private int y;
             private int x;

        public Tree(int xValue, int yValue)
        {
            x = xValue;
            y = yValue;
        }

        public void paintTree(Graphics g)
            {
                g.setColor(brown);
                g.fillRect(x+25, y+140, 20, 75);    //Tree stump
                g.setColor(Color.green);
                g.fillOval(x+5, y+118, 40, 40);     //Tree tops left
                g.fillOval(x+25, y+118, 40, 40);     //Tree tops right
                g.fillOval(x+15, y+110, 40, 40);     //Tree tops top
            }
        }


     public class Cloud
        {
            private int y;
            private int x;

            public Cloud(int xValue, int yValue)
                 {
                        x = xValue;
                        y = yValue;
                 }

                    public void paintCloud(Graphics g)
                        {
                            g.setColor(lightblue);
                            g.fillOval(x+100, y+50, 40, 30);
                            g.fillOval(x+90, y+45, 40, 30);
                            g.fillOval(x+80, y+55, 45, 35);
                            g.fillOval(x+110, y+55, 35, 35);

                        }
         }

              public class CrazyFruit
              {
                  private int y;
                  private int x;

                    public CrazyFruit(int xvalue, int yvalue)
                        {
                            x = xvalue;
                            y = yvalue;
                        }
                            public void paintCrazyFruit(Graphics g)
                                {
                                    g.setColor(Color.orange);
                                    g.fillOval(x-30, y+237, 7, 7);
                                    g.setColor(Color.blue);
                                    g.fillOval(x-40, y+235, 7, 7);
                                    g.fillOval(x-20, y+225, 7, 7);
                                    g.setColor(Color.red);
                                    g.fillOval(x-15, y+240, 7, 7);
                                    g.fillOval(x-5, y+232, 7, 7);
                                    g.setColor(Color.yellow);
                                    g.fillOval(x, y+225, 7, 7);

                                }


                }




}
<html>
   <head>
      <title>Repetitive Art</title>
   </head>

   <body>
  <h1>This is my Repetitive Art</h1>
  <applet width="500" height="500"  code="RepArt.class"></applet>
   </body>
</html>

First you need to read the API doc to see what classes JApplet extends.
Add an @Override statement before all the methods you are trying to extend to see if they are in a super class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.