LWUIT1.4带的LWUITDemo例子是基于NetBeans的.
把代码导入到Eclipse中(已经安装了MTJ插件)后,并在build path里添加了LWUIT.jar, 并在order & export中选中.
并设置了midlet后,编译可以运行,但是报找不到Resource.res资源.
但是例子包里没有这个资源.
怎么办呢?
例子文件夹里有build.xml文件,文件引用了NetBean的内容(通过导入build-impl.xml).
还不能直接运行,怎么办呢?
阅读build.xml文件后:发现这其实只是一个编译后处理的一个目标,实际就是编译需要的资源文件的.
把文件改成下面的样子,然后运行 post-compile target就可以在生成资源文件了,把资源文件拷贝到项目的res目录中就可以了.
其实改动了以下几个地方:
1、删除了导入外部build的内容.
2、删除了输出目录的变量<正确的方法是赋一个值>
<?xml version="1.0" encoding="UTF-8"?>
<project name="UIDemo" default="post-compile" basedir=".">
<description>Builds, tests, and runs the project .</description>
<target name="post-compile">
<delete dir="build" includes="**/Thumbs.db" />
<taskdef classpath="editor.jar" classname="com.sun.lwuit.tools.resourcebuilder.LWUITTask" name="build" />
<build dest="/resources.res">
<l10n name="localize">
<locale name="en" file="images/l10n/localize.properties" />
</l10n>
<font logicalName="SansSerif" size="20" charset=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-02" />
<font logicalName="Monospaced" size="10" />
<font logicalName="DialogInput" />
<font logicalName="Dialog" />
<image file="images/icons/Animations_sel.png" indexed="true" />
<image file="images/icons/Buttons_sel.png" indexed="true" />
<image file="images/icons/Dialogs_sel.png" indexed="true" />
<image file="images/icons/Layouts_sel.png" indexed="true" />
<image file="images/icons/Fonts_sel.png" indexed="true" />
<image file="images/icons/Rendering_sel.png" indexed="true" />
<image file="images/icons/Scrolling_sel.png" indexed="true" />
<image file="images/icons/Tabs_sel.png" indexed="true" />
<image file="images/icons/Themes_sel.png" indexed="true" />
<image file="images/icons/Transitions_sel.png" indexed="true" />
<image file="images/icons/Table_sel.png" />
<image file="images/icons/Tree_sel.png" />
<image file="images/icons/Animations_unsel.png" indexed="true" />
<image file="images/icons/Buttons_unsel.png" indexed="true" />
<image file="images/icons/Dialogs_unsel.png" indexed="true" />
<image file="images/icons/Fonts_unsel.png" indexed="true" />
<image file="images/icons/Layouts_unsel.png" indexed="true" />
<image file="images/icons/Rendering_unsel.png" indexed="true" />
<image file="images/icons/Scrolling_unsel.png" indexed="true" />
<image file="images/icons/Tabs_unsel.png" indexed="true" />
<image file="images/icons/Themes_unsel.png" indexed="true" />
<image file="images/icons/Transitions_unsel.png" indexed="true" />
<image file="images/icons/Table_unsel.png" />
<image file="images/icons/Tree_unsel.png" />
</build>
<build dest="/duke.res">
<animation file="images/duke3_1.gif" />
</build>
<build dest="/businessTheme.res">
<font createBitmap="false" name="boldMonospace" system="FACE_MONOSPACE; STYLE_BOLD ; SIZE_MEDIUM" />
<font createBitmap="false" name="proportionalSmall" system="FACE_PROPORTIONAL ; STYLE_PLAIN; SIZE_SMALL" />
<image file="images/themes/business_bar.jpg" indexed="true" />
<image file="images/themes/business_bg.jpg" indexed="true" />
<theme file="images/themes/business.conf" name="businessTheme" />
</build>
<build dest="/oceanfishTheme.res">
<font createBitmap="false" name="systemSmall" system="FACE_SYSTEM ; STYLE_PLAIN; SIZE_SMALL" />
<font createBitmap="false" name="systemMedium" system="FACE_SYSTEM ; STYLE_PLAIN; SIZE_MEDIUM" />
<font createBitmap="false" name="systemSmallBold" system="FACE_SYSTEM ; STYLE_BOLD; SIZE_SMALL" />
<font createBitmap="false" name="systemMediumBold" system="FACE_SYSTEM ; STYLE_BOLD; SIZE_MEDIUM" />
<animation file="images/themes/OceanFish.gif" />
<theme file="images/themes/OceanFish.conf" name="oceanfishTheme" />
</build>
<build dest="/images.res">
<image file="images/images/people.jpg" />
<image file="images/images/progress0.png" />
<image file="images/images/progress1.png" />
<image file="images/images/progress2.png" />
<image file="images/images/sady.png" indexed="true" />
<image file="images/images/smily.png" indexed="true" />
</build>
</target>
</project>