test049.java
package pack02;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class test049 extends JFrame
{
private final int OVAL_WIDTH = 80;
private final int OVAL_HEIGHT = 80;
public test049()
{
this.setTitle("graphic绘制圆形");
this.setContentPane(new MyDrawPanel());
this.setSize(500,500);
this.setVisible(true);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
private class MyDrawPanel extends JPanel
{
public void paint(Graphics g)
{
super.paint(g);
g.drawOval(10, 10, OVAL_WIDTH, OVAL_HEIGHT);
g.drawOval(80, 10, OVAL_WIDTH, OVAL_HEIGHT);
g.drawOval(150, 10, OVAL_WIDTH, OVAL_HEIGHT);
g.drawOval(50, 70, OVAL_WIDTH, OVAL_HEIGHT);
g.drawOval(120, 70, OVAL_WIDTH, OVAL_HEIGHT);
}
}
public static void main(String[] args)
{
test049 s1 = new test049();
}
}