我刚开始学习java,我画了一个五环怎么将它放在图像显示器的中央啊????
我刚开始学习java,我画了一个五环怎么将它放在图像显示器的中央啊????
package xiong;
import java.awt.Color;
import acm.graphics.GOval;
import acm.program.GraphicsProgram;
public class WuHuan extends GraphicsProgram
{
private int point_x = 100;
private int point_y = 200;
private static final int DIAMETER = 100;
private static final int SPACE = 20;
public void init()
{
setSize(800,800);
// TODO Auto-generated method stub
}
@Override
public void run()
{
GOval BLUE = new GOval(DIAMETER,DIAMETER);
BLUE.setColor(Color.BLUE);
add(BLUE,point_x,point_y);
GOval BLACK = new GOval(DIAMETER,DIAMETER);
BLACK.setColor(Color.BLACK);
add(BLACK,point_x + DIAMETER + SPACE,point_y);
GOval RED = new GOval(DIAMETER,DIAMETER);
RED.setColor(Color.RED);
add(RED,point_x + 2*DIAMETER + 2*SPACE,point_y);
GOval YELLOW = new GOval(DIAMETER,DIAMETER);
YELLOW.setColor(Color.YELLOW);
add(YELLOW,point_x + DIAMETER/2 + SPACE/2,point_y + DIAMETER/2);
GOval GREEN = new GOval(DIAMETER,DIAMETER);
GREEN.setColor(Color.GREEN);
add(GREEN,point_x + DIAMETER/2 + SPACE/2 + SPACE + DIAMETER,point_y + DIAMETER/2);
}
}