GWT Java仿真 [英] GWT Java Emulation

查看:73
本文介绍了GWT Java仿真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些使用java.awt.Color的代码。我想将我的Java代码翻译成GWT。
因此我将在我的GWT项目中模拟java.awt.Color。

一种方法是编写一个名为
的模块java.AWT.gwt .xml,其源路径为awt,类为java.awt.Color。



另一种方法是创建一个文件夹
com.google.gwt。 emul.java.awt
并在该路径内创建java.awt.Color类。 Eclipse会显示错误。但是编译器可以正常工作。

为GWT添加java.awt.Color的适当方法是什么?

解决方案

你宁愿在你想要的模块中创建一个子文件夹(也就是'超级')(可能是你想做的代码的模块可翻译的),并将它声明为 super-source 在你的模块的gwt.xml中:

 < super-source path =super/> 

然后你将 java / awt / Color.java code>在那里。



Eclipse错误是正常的,它不是应该编译的源代码(由javac编译为* .class文件)用于GWT编译的代码,它来自* .java文件。所以你想从构建路径中排除 super 子文件夹。



就是这样!



另请参阅 使用另一个子部分覆盖一个包实现 http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml


I have some code which uses java.awt.Color. I want to translate my Java Code to GWT. So I will emulate java.awt.Color in my GWT Project.

One approach is to write a module called java.AWT.gwt.xml whose source path is awt and a class called java.awt.Color.

The other approach is to create a folder com.google.gwt.emul.java.awt and create java.awt.Color class inside that path. Eclipse will show errors. But compiler will work.

Which one is appropriate way to add java.awt.Color for GWT?

解决方案

You'd rather create a subfolder (say 'super') in whichever module you want (probably the module for the code you want to make "translatable") and declare it as a super-source in your module's gwt.xml:

<super-source path="super" />

And you'd put your java/awt/Color.java in there.

The Eclipse errors are normal, it's not source code that should be compiled (by javac, to a *.class file), only code for the GWT compile, which works from the *.java file. So you'd want to exclude the super subfolder from your build path.

That's it!

See also the Overriding one package implementation with another subsection at http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml

这篇关于GWT Java仿真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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