用java 画一个杀老师

今天老师布置了作业,要画一个笑脸

辣么

就发挥一下o(* ̄▽ ̄*)o

画一个杀老师

第一步,找一张杀老师的表情包

第二步,打开IDEA,写一下代码

第三步,运行

代码如下:

import javax.swing.*;
import java.awt.*;
/*
Designed by ziyi
*/

public class Draw1 extends JFrame{
    MyPanel myPanel;
    public static void main(String[] args){// Instantiate a object
        Draw1 frame = new Draw1("Smile");
        frame.setVisible(true); //Show the window
    }

    public Draw1(String title){
        super(title);
        myPanel= new MyPanel();
        this.add(myPanel);//Set title of window
        setDefaultCloseOperation(EXIT_ON_CLOSE); // allow window to close
        setSize(600, 600);
    }

    class MyPanel extends JPanel{
        public void paint(Graphics graphics){
            graphics.setColor(Color.BLACK);
            graphics.fillRect(180,60,140,100);
            graphics.fillOval(140,30,220,60);
            graphics.setColor(Color.YELLOW);
            graphics.fillOval(100,100,300,300);
            graphics.setColor(Color.WHITE);
            graphics.fillOval(140, 220, 220, 140);            // 嘴巴露出微笑
            graphics.setColor(Color.YELLOW);
            graphics.fillOval(140, 220, 220,100);
            graphics.setColor(Color.BLACK);
            graphics.fillOval(180,70,140,80);

            graphics.fillOval(200,250,10,10);
            graphics.fillOval(300,250,10,10);
            graphics.drawLine(155,295,155,315);
            graphics.drawLine(345,295,345,315);
            graphics.drawLine(200,310,200,343);
            graphics.drawLine(300,310,300,343);
            graphics.drawLine(250,315,250,350);


        }
    }
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值