import java.awt.*;
/**
* Write a description of class Colour here.
*
* @author (Michael Kragh Pedersen)
* @version (Thursday, May 8th 2008)
*/
public class Colour extends Color
{
public Colour BLACK = new Colour((short) 0, (short) 0, (short) 0);
public Colour WHITE = new Colour((short) 255, (short) 255, (short) 255);
public Colour RED = new Colour((short) 255, (short) 0, (short) 0);
public Colour GREEN = new Colour((short) 0, (short) 255, (short) 0);
public Colour BLUE = new Colour((short) 0, (short) 0, 255);
private short red;
private short green;
private short blue;
/**
* Constructor for objects of class Colour
*/
public Colour(short r, short g, short b)
{
super(r, g, b);
red = r;
green = g;
blue = b;
}
}
Hvis jeg opretter et Colour objekt, ender jeg med at få en StackOverflow Error, da super kalder Colour i stedet for Color. Jeg går ud fra at det har noget at gøre med at Colour extender Color.
Hvis jeg fjerner super linjen, får jeg til gengæld en "cannot find symbol - Constructor Color".
Det jeg gerne vil, er at oprette min egen Colour klasse, som jeg så kan bruge præcis som jeg ville bruge et Color objekt, f.eks. bruge den i paint().
Men hvordan fikser jeg de errors?
Indlæg senest redigeret d. 08.05.2008 20:38 af Bruger #12726