代码:
import java.awt.Color;
import javax.swing.JFrame;
import java.awt.Graphics;
import javax.swing.JPanel;
public class MyPicture {
public static void main(String[] args) {
JFrame frame =new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("picture");
frame.setBackground(Color.BLACK);
frame.setBounds(300, 100, 800, 600);
Picture panel =new Picture();
frame.add(panel);
frame.setVisible(true);
}
}
class Picture extends JPanel{
public void paint(Graphics g){
g.setColor(Color.GREEN);
g.fillArc(260,200,150,150,180,90);
g.setColor(Color.BLACK);
g.fillArc(280,200,150,150,180,90);
g.setColor(Color.GREEN);
g.fillArc(180,80,50,70,0,360);
g.fillArc(180,200,50,70,0,360);
g.fillArc(310,80,50,70,0,360);
g.fillArc(310,200,50,70,0,360);
g.fillArc(240,50,60,90,0,360);
g.fillArc(200,100,140,180,0,360);
g.setColor(Color.BLACK);
g.fillArc(250,60,10,10,0,360);
g.fillArc(280,60,10,10,0,360);
g.drawLine(230,190,250,230);
g.drawLine(230,190,250,150);
g.drawLine(310,190,290,150);
g.drawLine(310,190,290,230);
g.drawLine(250,150,290,150);
g.drawLine(250,230,290,230);
}
}
|
|