⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circlesadded.java

📁 画8个同心圆 可以调节色彩
💻 JAVA
字号:
//Lab 13:Circles.java
//This program draws concentric circles
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CirclesAdded extends JFrame{
	
	
	//constructor
	public CirclesAdded (){
		super( "Circles" );
		setSize( 300, 300);
		setVisible( true );
	}

	//draw eight Circles separated by 10 pixels
	public void paint( Graphics g ){
		
		super.paint( g );

		//create 8 concentric circles
		/*Create a for loop that loops eight time. In the body of the loop,
		  calculate the side of the box bounding the arc and use drawArc to
		  display a circle.*/ 
		for (int topLeft=0,topLeftCorner=50,side;topLeft<=7;topLeft++)
		{
              g.setColor(new Color ((float)Math.random(),(float)Math.random(),(float)Math.random()));
			  side=160 - (20*topLeft);
			  topLeftCorner+=10;
			  g.drawArc(topLeftCorner,topLeftCorner,side,side,0,360);
			  
		}
	}

	public static void main( String args[] ){
		CirclesAdded application = new CirclesAdded();
		application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
	}
}//end class Circles

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -