applet显示框架代码
来源:互联网 发布:数据系统txt下载 编辑:程序博客网 时间:2024/05/17 08:33
package csdn.net.shao;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
/**
*全代码抄录java编程思想加入了2个函数适应不同的显示组件
*/
public class FrameWork
{
//创建一个class名称的字符串
public static String title(Object o)
{
String t=o.getClass().toString();
//删除tostring()得到的class 的字符
if(t.indexOf("class")!=-1)
t=t.substring(6);
return t;
}
public static void setupClosing(JFrame frame)
{
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}});
}
public static void run(JFrame frame,int width,int height)
{
setupClosing(frame);
frame.setSize(width,height);
frame.setVisible(true);
}
public static void run(JApplet applet,int width,int height)
{
JFrame frame=new JFrame(title(applet));
setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(width,height);
applet.init();
applet.start();
frame.setVisible(true);
}
public static void run(Applet applet,int width,int height)
{
JFrame frame=new JFrame(title(applet));
setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(width,height);
applet.init();
applet.start();
frame.setVisible(true);
}
public static void run(JPanel panel,int width,int height)
{
JFrame frame=new JFrame(title(panel));
setupClosing(frame);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}
public static void run(Panel panel,int width,int height)
{
JFrame frame=new JFrame(title(panel));
setupClosing(frame);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}
}
应用时,比如说有一个public class A extends JApplet
那么先 import csdn.net.shao.FrameWork;
在你原先的applet代码的最后一个}前面加上
public static void main(String[] args)
{
FrameWork.run(new A(),200,50);
}
即可直接将applet frame panel japplet jpanel在editplus,ultraledit ,jcreator等软件中直接执行.
- applet显示框架代码
- 浏览器无法显示嵌入网页代码中的Applet java程序
- imx6 显示代码框架
- BREW Applet框架
- BREW Applet框架
- BREW Applet框架
- applet 不能显示解决方法
- 用APPLET显示图片
- applet 显示图片问题
- Applet 代码签名
- 在Applet中显示图片
- applet支持多媒体示例代码
- JFreechart tips:使用applet来显示图表
- 关于APPLET中显示图片的问题
- Java源代码-Applet-居中显示文字
- Java Applet应用:显示图片、播放声音
- applet在html中无法显示 解决方法
- 将Applet嵌入页面并显示
- 我的gmail有六个邀请,想要的和我联系
- 感悟
- 假的!假的!
- (方志文)MutableGridLayout布局管理器使用说明
- 访问控制
- applet显示框架代码
- VC学习资料收集(5):剖析VC中的文件操作
- 有人看过2001 的书吗?
- 江南水乡
- VC实例学习 (2):今天的学习记录
- 排序算法小结
- Borland Delphi2005发布
- 换了你,你会杀了谁?
- vs2003 创建web应用程序出错:配置应用程序根错误......