Java Solaris Communities Partners My Sun Sun Store China Worldwide
»   简介
» 简要了解 Sun SPOT
»   Ectoplasmic Bouncing Ball 演示程序
»   加载和运行 Air Text 演示程序
    更改 Air Text 演示程序(当前页)
» 基站实战
 
Sun SPOT 快速入门教程

更改 Air Text 演示程序

 
 

更改 Air Text 演示程序相当简单。

首先,复制已有项目。右键单击 "AirText" 并从菜单中选择 "Copy Project"。

A NetBeans screenshot. The AirText project has been selected and the pop-up menu is displayed.  The cursor is positioned over the choice 'Copy Project'.

此时将出现一个对话框。为您自己的项目输入一个新名称:

A dialog box screenshot. The dialog box is titled 'Copy Project.'  The input area lableld 'Project Name' has been filled in with the name 'AirText_New'. The cursor is positioned over a button reading 'Copy'.

将新项目设置为当前项目,方法是单击项目名称并选择 "Set Main Project"。在项目窗口中,单击项目左侧的加号展开项目节点。现在,依次展开 "src" 节点和 "org.sunspotworld.demo" 包。从显示的文件中选择 "AirTextDemo.java"。打开文件,双击它或右键单击并选择 "Open"。

A NetBeans screenshot. In the upper left, the Files tab has been selected.  The active project is now 'AirText_New'.  It has been selected and the source (SRC) node has been expanded.  Under the source node, the node shown is 'org.sunspotworld.demo'.  Under that node, three source files are visible and on of them has been selected.  The selected source file is 'AirTextDemo.java'.  The beginning of that file are shown in an editor window to the right.

AirTextDemo.java 的源代码将显示在右侧窗口中。滑动鼠标滑轮找到大约第 50 行。您会看到一系列 disp.SwingThis 调用。将字符串 "Hi!" 更改为 "Yes!"。

A NetBeans screenshot. The AirTextDemo.java file is open in the editor window and the window is scrolled a little bit more than half way through the file.  The source shown in the screenshot reads, in part, 'while (true) { disp.setColor(255,0,0); disp.swingThis('HI!', 17);'  The statement beginning 'disp.swingthis' is circled in the figure.

现在,检查之前的步骤正确无误,然后部署并运行新代码。在部署时,系统会自动保存和编译您的修改。

拔下 Sun SPOT 的 USB 插头。然后,将它在空中摇摆几下,查看您的修改是否已经反映在 Sun SPOT 上。

祝贺您!您已经掌握了 Sun SPOT 的 "Hello, world" 应用程序!

接下来,我们将介绍 如何使用 Sun SPOT 基站连接移动 Sun SPOT


下一页:基站实战

返回顶部