Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Drawing a circle with Dr.Java

807599Nov 13 2006 — edited Nov 14 2006
Hello,
Im very new to java and in fact im taking it in a computer course from my university. Im having great difficulties with some of the things i have to do. I need to create new objects and i just dont know how to. I have tried several times on my own but i get errors when i compile or it just dosent work. I need to create circles, semi-circles and triangles. This is the code that was give to me to use:

/**
* Part 0
* Circle and semicircle
*/

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

public class Part0 extends Applet {

// Instance variables
// Image location.
// Diameter of each shape.
// Colour of each shape.
// Angles for the semicircle.

private Location imageLocation;
private Angles angles;
private int semiDiameter;
private int circleDiameter;
private Color circleColor;
private Color semiColor;
private Location semiOffset;
private Location circleOffset;
private ColouredSemiCircle semi;
private ColouredCircle circle;

/**
* Initialize the variables needed to
* describe the two shapes.
*/
public void init() {

imageLocation = new Location(50, 100);
semiOffset = new Location(0, 0);
circleOffset = new Location(-30, 50);
circleDiameter = 100;
semiDiameter = 30;
angles = new Angles(0, 180);
circleColor = new Color(255, 125, 0);
semiColor = new Color(125, 125, 125);
// Using these, variables to create the body.
circle = new ColouredCircle(circleDiameter, imageLocation, circleOffset,
circleColor);
semi = new ColouredSemiCircle(semiDiameter, imageLocation, semiOffset,
angles, semiColor);
}

// Part of the applet not used in Part0.
public void start() {
}

// Part of the applet not used in Part0.
public void stop() {
}

// Part of the applet not used in Part0.
public void destroy() {
}

/**
* Display the shapes created in this Applet.
*/
public void paint (Graphics g) {
semi.paint(g);
circle.paint(g);
}
}

Any help at all will be very much appreciated!
Ashley
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2006
Added on Nov 13 2006
3 comments
326 views