新手记录一下自己做的题
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)