java画乌龟(略丑)

效果图:

MyPanel.java

import java.awt.*;
class MyPanel extends Panel{
	public void paint(Graphics g){
		g.setColor(Color.yellow);
		g.fillOval(123, 30, 30, 35);
		g.fillOval(90, 70, 40, 10);
		g.fillOval(90, 90, 45, 10);
		g.fillOval(150, 70, 40, 10);
		g.fillOval(150, 90, 45, 10);
		g.fillOval(135, 105, 15, 40);
		g.setColor(new Color(62,174,26));
		g.fillOval(110, 50, 60, 70);
		g.setColor(Color.white);
		g.drawLine(120, 60, 130, 70);
		g.drawLine(130, 70, 145, 70);
		g.drawLine(145, 70, 160, 60);
		g.drawLine(130, 70, 130, 90);
		g.drawLine(130, 90, 115, 100);
		g.drawLine(130, 90, 145, 90);
		g.drawLine(145, 90, 165, 100);
		g.drawLine(145, 90, 145, 70);
		g.setColor(Color.black);
		g.fillOval(140, 40, 5,5);
		g.fillOval(130, 40, 5,5);
	}
}

 

MyTest.java

import java.awt.*;
import java.awt.event.*;
public class MyTest{
	public static void main(String args[]){
		Frame f = new Frame();
		MyPanel mp = new MyPanel();
		f.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
		f.add(mp);
		f.setSize(300,300);
		f.setLocationRelativeTo(null);
		f.setVisible(true);
	}
}

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值