GWT Java Emulation

限于喜欢 提交于 2019-12-04 14:07:15

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/6457047/gwt-java-emulation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!