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

📄 appletframe.java

📁 ASCII图画分类: 图像处理 可以将鼠标画的图象转成ASCII的形式
💻 JAVA
字号:

package joeh.asciidraw;
import java.awt.*;
import java.applet.*;
import java.util.*;
import java.io.*;



//The appletframe was written by someone else, okay?
//A real simple piece of reusable code.  Everybody's using it.
//Sorry, I forgot who the copyright holder is... But I do remember it saying
//"Please use this code" I don't know about re-sell though.  Honestly, you should
//check Gamelan please.  Copyright laws are cool.  We should respect them. 
class AppletFrame extends Frame {

	public static void startApplet(String className, 
		   String title, 
		   String args[])  {
	// local variables
	Applet a;
	Dimension appletSize;

	try {
	// create an instance of your applet class
	a = (Applet) Class.forName(className).newInstance();
	}
	catch (ClassNotFoundException e) { return; }
	catch (InstantiationException e) { return; }
	catch (IllegalAccessException e) { return; }

	// initialize the applet
	a.init();
	a.start();
	a.resize(200,200);

	// create new application frame window
	AppletFrame f = new AppletFrame(title);

	// add applet to frame window
	f.add("Center", a);

	// resize frame window to fit applet
	// assumes that the applet sets its own size
	// otherwise, you should set a specific size here.
	appletSize =  a.size();
	f.pack();
	//       f.resize(appletSize);  
	f.resize(200,200);
	// show the window
	f.show();

}  // end startApplet()


// constructor needed to pass window title to class Frame
public AppletFrame(String name) {
	// call java.awt.Frame(String) constructor
	super(name);
}

// needed to allow window close
public boolean handleEvent(Event e)
{
// Window Destroy event
if (e.id == Event.WINDOW_DESTROY) {
// exit the program
System.exit(0);
return true;
}

// it's good form to let the super class look at any 
// unhandled events
return super.handleEvent(e);

}  // end handleEvent()

}   // end class AppletFrame

⌨️ 快捷键说明

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