shapespanel.java

来自「一个java图形绘制程序」· Java 代码 · 共 32 行

JAVA
32
字号
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;


public class ShapesPanel extends JPanel
{

public void paintComponent(Graphics g) {	 
		super.paintComponent(g);
    

		int width = getWidth();
		int height = getHeight();
		g.setColor(Color.white); 
 g.fillRect(0, 0, width, height);
 
		//draw the ciclier 
		int radius = width/10;
		g.setColor(Color.green);	
		g.fillOval(3*width/10, 3*height/10, radius, radius);
		//draw the Rect	 
		g.setColor(Color.orange);
	 	g.fillRect(6*width/10, 7*height/10, width/10, 2*height/10);
		 
		//draw the line 
		g.setColor(Color.black);
		g.drawLine(40,40,200,40) ;
	}

}

⌨️ 快捷键说明

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