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

📄 drawtest.java

📁 递归子程序法:对应每个非终结符语法单元编一个独立的处理过程(或子程序)。语法分析从读入第一个单词开始
💻 JAVA
字号:
	package drawtest;
	/** 
	 * Java语言实验参考程序
	 * Company 北京师范大学计算机系 
	 * @author 孙一林
	 * @version 1.0
	 */
	import java.awt.*;
	public class DrawTest extends Frame {				// 创建程序框架
    	public DrawTest() {
		setLayout(new BorderLayout());
		DrawPanel display = new DrawPanel();			// 创建绘图对象
		add("Center", display);
	    }
	    public boolean handleEvent(Event e) {			// 处理结束程序事件
			switch (e.id) {
			  case Event.WINDOW_DESTROY: System.exit(0); return true;
			  default:	return false;
			}
	    }
	    public static void main(String args[]) {		// 定义程序入口
			DrawTest drawTest = new DrawTest();
	        drawTest.setTitle("画图程序");
	        drawTest.setSize(500,300);
	        drawTest.show();
	    }
	}
	class DrawPanel extends Panel {
	    public void paint(Graphics g) {
	      g.drawLine(10,10,30,30);					// 画线
	      g.drawLine(15,20,15,20);					// 画点
	      g.drawRect(40,10,60,30);					// 画矩形
	      g.fillRect(120,10,60,30);
	      g.drawRoundRect(200,10,50,30,20,20);		// 画圆角矩形
	      g.fillRoundRect(280,10,50,30,40,30);
	      g.drawRoundRect(360,10,50,30,50,30);
	      g.draw3DRect(20,60,80,60,true);			// 画立体矩形
	      g.fill3DRect(120,60,80,60,false);
	      int Poly1_x[]={230,263,315,272,267};
		  int Poly1_y[]={60,40,115,94,126};
	      int Poly1_pts=Poly1_x.length;
	      int Poly2_x[]={380,413,465,422,417};
		  int Poly2_y[]={60,40,115,94,126};
	      int Poly2_pts=Poly2_x.length;
	      g.drawPolygon(Poly1_x,Poly1_y, Poly1_pts);
	      g.fillPolygon(Poly2_x,Poly2_y, Poly2_pts);
	      g.drawOval(30,150,60,60);  g.fillOval(130,150,80,60);	// 画椭圆
	      g.drawArc(210,150,100,60,35,-140);						// 画弧
		  g.fillArc(310,150,100,60,35,65);
	    }
	}

⌨️ 快捷键说明

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