Question

I have been struggling to get acm graphics to display in eclipse. When I simply run the below code, the applet starts but nothing is displayed. The class is in default package in the source directory. Thanks in advance for any feedback.

import acm.graphics.*;
import acm.program.GraphicsProgram;
import java.awt.Color;

public class run extends GraphicsProgram{

public void oval() {
    GOval ov = new GOval(50,50,50,50);
    ov.setFilled(true);
    ov.setColor(java.awt.Color.green);
    add(ov);
}

}
Était-ce utile?

La solution

Use the GraphicsProgram init method which will be called automatically

public void init() {
   GOval ov = new GOval(50,50,50,50);
   ...
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top