简体   繁体   中英

GWT Java Emulation

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM