Domanda

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);
}

}
È stato utile?

Soluzione

Use the GraphicsProgram init method which will be called automatically

public void init() {
   GOval ov = new GOval(50,50,50,50);
   ...
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top