设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> Java >> Converting between applets and applications
精品推荐
Java点击TOP10
·java笔试题
·《Thinking in Java》读书笔记
·JSP的mysql_jdbc驱动程序
·异常java.sql.SQLException: Io exception:The Network Adapter could not establish connection
·Java Coder 常用软件下载地址
·Java图形界面开发:SWT全接触
·org.apache.commons.dbcp.SQLNestedException解决办法
·如何使用Java POI生成Excel表文件 !
·功能强大的在线网页编辑器
·一些非常不错的Struts 例子下载
编程开发点击TOP10
·ASP.NET 程序中常用的三十三种代码
·利用ASP.NET构建网上考试系统
·C#版的网站新闻发布系统
·(转)23种设计模式汇集
·设计ASP.NET新闻管理系统
·深山红叶袖珍PE工具箱V16正式版
·我的.NET书架 (入门篇)
·java笔试题
·网页打印问题,打印设置,打印预览,打印分页,纵打,横打及页面的边距
·.NET:是什么?将走向哪里?
精选专题

Converting between applets and applications

作者: 来源:网络文章 时间:2005-12-14 17:23:58

Converting between applets and applications(1)

Converting between applets and applications
To convert an Application to Applet:
  1. Create an HTML page with an applet tag to invoke the applet.
  2. Delete the main method.
  3. Alter the class header so that it extends Applet rather than Frame.
  4. Add the import for the library class Applet.
  5. Change the name of the constrUCtor method from the name of the class to init.
  6. Add an invocation of a method to set the layout of widgets in the applet window.
This is typically:
setLayout(new BorderLayout());

To convert a Applet to Application:
  1. Change the name of the init method to the name of the class. This is now the constrUCtor method for the class. Delete the Word void in the header for this method, since a constrUCtor method has no return type.
  2. Alter the class header so that it extends Frame rather than Applet.
  3. Create a new method called main, with the header public static void main(String[] args).  This is now the constrUCtor method should create a Frame object as an instance of the class. So, if the class is called MyClass, the main method should be:
public static void main(String[] args){
    MyClass f = new MyClass();
    f.setSize(300, 200);
    f.setVisible(true);
}
  1. Delete the import for the class Applet, since it now redundant.
  2. Add a method windowClosing to handle the event which is the user clicking on the close window button. This also involves adding implements WindowListener and this.addWindowListener(this); in order to register the event handler.
  3. Add an invocation of a method to set the layout of widgets in the frame.
This is typically:
setLayout(new FlowLayout());
Make sure that the applet does not use any of the methods that are special to the Applet class - methods including getAudioClip, getCodeBase, getDocumentBase, GetImage.
 
共2页 9 7 [1] [28 :>

Converting between applets and applications 相关文章:
Converting between applets and applications 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com