This discussion is archived
1 Reply Latest reply: Oct 17, 2012 4:00 AM by Tolls RSS

Rectangle  within and applet

968909 Newbie
Currently Being Moderated
In writing a simple program for rectangle I am getting an error.

The method setDimensions(int, int) is undefined for the type Rectangle

Here is my program:

import java.awt.*;
import java.applet.*;

public class RectangleTest extends Applet{

     Rectangle r = new Rectangle();
     
     public void init(){
          
          r.setDimensions(3,4);
          
     }
     
     public void paint (Graphics g){
          g.drawString("The area of rectangle r is " + r.area(),20,20);
     }
}

Thoughts?

Please and Thank you - btw - I am new to java

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points