这是一个简单的图形程序,可以在屏幕上添加一些星星.
import acm.graphics.*;
import acm.program.*;
import java.awt.event.*;
import javax.swing.*;
/**
* This program creates a five-pointed star every time the
* user clicks the mouse on the canvas.
*/
public class DrawStarMap1 extends GraphicsProgram {
public void init() {
/* Initializes the mouse listeners */
addMouseListeners();
/* The check box starts out in the "on" position */
fillCheckBox = new JCheckBox("Filled");
fillCheckBox.setSelected(true);
add(fillCheckBox, SOUTH);
/* Clears the screen with a button */
add(new JButton("Clear"), SOUTH);
addActionListeners();
}
/* Called whenever …Run Code Online (Sandbox Code Playgroud)