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

📄 graphicstest.java

📁 JAVA网络编程电子书及源码
💻 JAVA
字号:
package ch01;

import java.applet.*;
import java.awt.*;
/**
 * 在这里插入类型说明。
 * 建立日期:(00-8-23 22:27:06)
 * @程序设计者:
 */
public class GraphicsTest extends Applet {
	Font font = new Font("Dialog", Font.BOLD, 24);
	String str = "欢迎使用 VisualAge " ;
	int xPos = 5;
/**
 * 返回有关 applet 的信息。
 * @return 返回有关 applet 信息的字符串。
 */
public String getAppletInfo() {
	return "GraphicsTest\n" + 
		"\n" + 
		"在这里插入类型说明。\n" + 
		"建立日期:(00-8-23 22:27:03)\n" + 
		"@程序设计者:\n" + 
		"";
}
/**
 * 初始化 applet。
 * 
 * @see #start
 * @see #stop
 * @see #destroy
 */
public void init() {
	super.init();

	// 在这里插入代码以初始化代码
}
/**
 * 在这里插入方法说明。
 * 建立日期:(00-8-24 20:27:12)
 */
public static void main(java.lang.String[] args) {
	GraphicsTest app = new GraphicsTest();
	java.awt.Frame frame = new java.awt.Frame("Applet");

	
	frame.add("Center", app);
	frame.setSize(500,500);
	frame.show();

	app.init();
	app.start();

}
/**
 * 在绘图区域绘制文本。
 * @param g 指定的图形窗口
 */
public void paint(Graphics g) {
	g.setFont(font);
	g.setColor(Color.white);
	g.drawString(str, xPos, 50);
	Rectangle r=new Rectangle(700,700);
	g.setColor(Color.white);
	g.fillRect(r.x,r.y,r.width,r.height);
	g.setColor(Color.black);
	g.drawOval(10,10,50,50);
	g.fillOval(70,10,50,50);
	g.drawArc(130,10,50,50,-90,270);
	g.fillArc(190,10,50,50,-90,270);
	g.drawRect(10,70,50,50);
	g.fillRect(70,70,50,50);
	g.drawRoundRect(130,70,50,50,10,10);
	g.fillRoundRect(190,70,50,50,10,10);
	Polygon thePoly=new Polygon();
	thePoly.addPoint(10,130);
	thePoly.addPoint(70,150);
	thePoly.addPoint(120,130);
	thePoly.addPoint(120,180);
	thePoly.addPoint(70,170);
	thePoly.addPoint(10,180);
	thePoly.addPoint(10,130);
	g.drawPolygon(thePoly);
	thePoly=new Polygon();
	thePoly.addPoint(130,130);
	thePoly.addPoint(190,150);
	thePoly.addPoint(240,130);
	thePoly.addPoint(240,180);
	thePoly.addPoint(190,170);
	thePoly.addPoint(130,180);
	thePoly.addPoint(130,130);
	g.fillPolygon(thePoly);
	g.setColor(Color.gray);
	g.draw3DRect(10,190,50,50,true);
	g.fill3DRect(70,190,50,50,true);
	g.draw3DRect(130,190,50,50,false);
	g.fill3DRect(190,190,50,50,false);
	
}
}

⌨️ 快捷键说明

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