将 JFrame 转换为 JApplet [英] Converting a JFrame to a JApplet

查看:34
本文介绍了将 JFrame 转换为 JApplet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行良好的 JFrame 应用程序.但是现在我想将它作为小程序在网络上运行.这就是我所做的:

I have a JFrame application working nicely. However now I'd like to run it on the web as an Applet. This is what I've done:

import MyPackage.*;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

public class MyName extends JApplet
{

     public void init() {
        setSize(600,450);
        new MyName()
     }

    public MyName() {
        JShellFrame frame = new JShellFrame(true, null, null);
        frame.setVisible(true);
    }

}

我如何制作一个 html 文件来运行这个小程序?另外,我有一个小程序需要的外部 jar 文件.小程序不需要main方法吗?

How can I make an html file to run this applet? Also, I have an external jar file that the applet will need. Does the applet not need a main method?

推荐答案

查看 Applet 入门.它涵盖了相关的方法生命周期.它还提到了 main 方法:

Check out Getting Started With Applets. It covers relevant methods and life cycle. It mentions main method as well:

与 Java 应用程序不同,applet 不需要实现 main方法.

Unlike Java applications, applets do not need to implement a main method.

部署 部分涵盖 HTML 文件详细信息.对于依赖 jar,您可以在 applet 标签的 archive 属性中指定多个 jar.

Deployment section covers HTML file details. For dependency jars you can specify more than one jar in archive attribute of applet tag.

这篇关于将 JFrame 转换为 JApplet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆