JAVASWING打印奥运五环

新手记录一下自己做的题

import javax.swing.JFrame;

public class Drawaoyunwuhuan {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Drawaoyunwuhuan draw = new Drawaoyunwuhuan();
		JFrame jFrame = new JFrame("奥运五环");
		DrawCan can =new DrawCan();
		jFrame.add(can);
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//增加关闭功能
		jFrame.setSize(1000,1000);
		jFrame.setVisible(true);

	}

}
---------------------------类的分割线-----------------------------------
import java.awt.BasicStroke;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class DrawCan  extends Canvas{
public void paint(Graphics g) {
	    Graphics2D gg = (Graphics2D)g;
	    gg.setStroke(new BasicStroke(15.0f));//加粗
		g.setColor(Color.BLUE);
		g.drawRoundRect(200, 200, 240, 240, 360, 360);
		g.setColor(Color.BLACK);
		g.drawRoundRect(400, 200, 240, 240, 360, 360);
		g.setColor(Color.RED);
		g.drawRoundRect(600, 200, 240, 240, 360, 360);
		g.setColor(Color.YELLOW);
		g.drawRoundRect(300, 400, 240, 240, 360, 360);
		g.setColor(Color.GREEN);
		g.drawRoundRect(500, 400, 240, 240, 360, 360);
	}

}

![原题目](https://img-blog.csdnimg.cn/20201202103848790.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MTEzMzI4MA==,size_16,color_FFFFFF,t_70)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值