如何显示GWT页面内的Java小程序? [英] How to display java applet inside GWT page?

查看:134
本文介绍了如何显示GWT页面内的Java小程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能失去了一些东西简单在这里,但我不能在其他地方找到答案。我只是想在我的GWT code显示的小程序。

I'm probably missing something simple here, but I can't find the answer elsewhere. I just want to display an applet in my GWT code.

操作系统:Windows XP
Java的:JDK 1.6.0_10
其他:GWT,GWT-Ext的2.0.5

OS: Windows XP Java: JDK 1.6.0_10 Other: GWT, GWT-Ext 2.0.5

下面是小程序(明显简化了测试):

Here is the applet (obviously simplified for testing):

package foo.applet;

import javax.swing.JApplet;
import java.awt.Graphics;

public class HelloApplet extends JApplet 
{
    public void paint(Graphics g) 
    {
        g.drawRect(0, 0, 
                   getSize().width - 1,
                   getSize().height - 1);
        g.drawString("Hello world!", 5, 15);
    }
}

下面是code调用它:

Here is the code calling it:


package foo.applet;

import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.widgets.Panel;


public class AppletPanel extends Panel 
{

public AppletPanel()
{
    HTML applet = new HTML();
    applet.setHTML("<applet name=\"HelloApplet\" code=\"HelloApplet.class\" width=\"300\" height=\"300\"" );
    this.add(applet);
}

}

当我启动的应用程序在托管模式,JVM的崩溃(提交事件1425130与Sun)。

When I launch the app in hosted mode, the jvm crashes (filed incident 1425130 with Sun).

当我尝试编译GWT code在浏览器中运行,我得到这样的:

When I try to compile the GWT code for running in a browser, I get this:

        [ERROR] Errors in 'file:/C:/<blah>/applet/HelloApplet.java'
           [ERROR] Line 3: The import javax.swing cannot be resolved
           [ERROR] Line 4: The import java.awt cannot be resolved
           [ERROR] Line 6: JApplet cannot be resolved to a type
           [ERROR] Line 8: Graphics cannot be resolved to a type
           [ERROR] Line 11: The method getSize() is undefined for the type HelloApplet
           [ERROR] Line 12: The method getSize() is undefined for the type HelloApplet

很显然,我错过了一些小程序库,但我已经通过JDK中的所有的罐子grepped并试图包括所有列举JApplet的或AWT的那些的(plugin.jar,resources.jar,rt.jar中,部署的.jar,javaws.jar)。

Obviously I'm missing some applet library, but I've grepped through all the jars in the jdk and tried including all of the ones that list JApplet or awt (plugin.jar, resources.jar, rt.jar, deploy.jar, javaws.jar).

此外,我pretty肯定,一旦我解决这个问题还有另外一个后马上潜伏,但我会保存为另一个问题。

Also, I'm pretty sure once I solve this problem there's another one lurking right after it, but I'll save that for another question.

谢谢!

继承应用程序不是一个小程序 - 这是一个胖客户端的Swing应用程序。我们已经侵入它作为一个小程序,因为我们的客户需要一个浏览器客户端来运行,这是弄完的最快方法。

The legacy app is not an applet - it is a thick-client Swing application. We've hacked it to run as an applet because our customers want a browser client and this is the fastest way to get that done.

我不知道是否会GWT接受的JPanel的解决方案 - 应用程序是不是写在任何方式,GWT可以解析 - 即它不使用GWT的API,它使用了Swing API。据我所知,混合使用GWT摇摆的唯一途径将是一个applet的方式。

I don't know if GWT would accept the JPanel solution - the app is not written in any way that GWT can parse - i.e. it's not using the GWT API, it's using the Swing API. AFAIK, the only way to mix Swing with GWT would be in an applet fashion.

我缺少的东西吗?

推荐答案

您想GWT编译你的applet?

Are you trying to GWT-compile your applet?

这是行不通的,因为GWT编译(这是从Java为Javascript只是翻译)支持的Java库只有极少数,当然不是小程序。

This won't work, as GWT compilation (which is just translation from Java to Javascript) supports only handful of Java libraries and certainly not applets.

请确保您的小程序是不是GWT源路径(移动到另一个包)上。

Make sure that your applet is not on GWT source path (move it to another package).

参考:<一href=\"http://$c$c.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=RefJreEmulation\">http://$c$c.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=RefJreEmulation

这篇关于如何显示GWT页面内的Java小程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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