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

📄 taichi.java

📁 使用java代码
💻 JAVA
字号:
/**
 * @(#)Taichi.java
 *
 *
 * @author 
 * @version 1.00 2007/6/12
 */
import javax.swing.*;
import java.awt.*;

public class Taichi extends JFrame 
{
        
    /**
     * Creates a new instance of <code>Taichi</code>.
     */
    public Taichi() 
    {
    	setSize(width,height);
    	setTitle("太极图");
    	Toolkit kit=Toolkit.getDefaultToolkit();
    	Dimension screenSize=kit.getScreenSize();
    	int x=(screenSize.width-width)/2;
    	int y=(screenSize.height-height)/2;
    	setLocation(x,y);
    	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        // TODO code application logic here
        Taichi frame=new Taichi();
        DrawPanel drawPanel=new DrawPanel();
        frame.setContentPane(drawPanel);
        frame.setVisible(true);
    }
    int width=400;
    int height=300;
}

class DrawPanel extends JPanel
{
	public DrawPanel()
	{
		setBackground(Color.GRAY);
	}
	
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		g.setColor(Color.BLACK);
		g.fillArc(x,y,d,d,0,180);
		g.setColor(Color.WHITE);
		g.fillArc(x,y,d,d,180,180);
		g.setColor(Color.BLACK);
		g.fillArc(x+d/2,y+d/4,d/2,d/2,180,180);
		g.setColor(Color.WHITE);
		g.fillArc(x,y+d/4,d/2,d/2,0,180);
		g.fillOval(x+d*3/4-5,y+d/2-5,10,10);
		g.setColor(Color.BLACK);
		g.fillOval(x+d/4-5,y+d/2-5,10,10);
	}
	
	int x=100;
	int y=40;
	int d=200;
}

⌨️ 快捷键说明

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