package ydj; import java.awt.*; import javax.swing.*; public class huayuan extends JFrame { public huayuan() { mianban mb=new mianban(); Container content=getContentPane(); this.setVisible(true); this.setSize(400, 400); content.add(mb); mb.setBackground(Color.WHITE); mb.setForeground(Color.GREEN); } class mianban extends JPanel { public void paint(Graphics g) { super.paint(g); g.drawOval(500,100,100,100); //第一层 g.drawOval(300,200,100,100); //第二层第一个 g.drawOval(700,200,100,100); //弟二层第二个 g.drawOval(150,300,100,100); //第三层第一个 g.drawOval(400,300,100,100); //第三层第二个 g.drawOval(550,300,100,100); //第三层第三个 g.drawOval(800,300,100,100); //第三层第四个 g.drawOval(250,400,100,100); //第三层第一个 g.drawLine(510,175,390,225); g.drawLine(600,150,715,215); g.drawLine(310,275,150,300); //g.drawLine(300,200,400,300); } } public static void main(String args[]) { huayuan c=new huayuan(); } }