站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Netbeans 专题Developing Applications for TiVo in NetBeans

Developing Applications for TiVo in NetBeans

摘要: The TiVo folks have a Java SDK for writing applications that run on a TiVo (well actually the code runs on the server, and the visualization happens on the user's TV), along with a simulator that lets you run and debug applications on your computer. Here's how to very simply set up NetBeans to run/debug TiVo applications

The TiVo folks have a Java SDK for writing applications that run on a TiVo (well actually the code runs on the server, and the visualization happens on the user's TV), along with a simulator that lets you run and debug applications on your computer. Here's how to very simply set up NetBeans to run/debug TiVo applications.

These instructions are for a current NetBeans 4.1 development build, but the process is very similar for NetBeans 4.0.

First, you will need to download the TiVo SDK, and unpack it to, e.g., /tivo

Now, in NetBeans:

  1. Select File | New Project to open the New Project Wizard.
  2. Select the General category in the left-hand pane, and Java Application in the right-hand pane, and press Next. On the next pane of the wizard name the project TivoTest, and press Finish to create the project.
  3. Right click the TivoTest node in the Projects tab of the Explorer window (to the left of the editor) and choose Properties from the popup menu that appears, to show the Project Properties dialog.
  4. Select the Build | Compiling Sources node in the left-hand pane of that dialog, and Click the Add Library button on the right. This displays a list of libraries NetBeans already knows about. If this is the first time you've used the TiVo SDK, you'll need to set it up as a library; otherwise, steps 5 through 7 can be skipped.
  5. Click the Manage Libraries button in this dialog. In the next dialog, click New Library at the bottom left. In the New Library dialog, type Tivo and press enter to close the dialog.
  6. The Library Manager dialog will now show a new library on the left called Tivo, with no contents. Click the Add Jar/Folder button on the left. In the file dialog that appears, navigate to wherever you unpacked the TiVo SDK. Select hme.jar and simulator.jar, and press the Add JAR/Folder button at the bottom of the file dialog to accept them.
  7. Now switch to the Sources tab, and click its Add JAR/Folder button, and add src.zip, so code completion is available for the TiVo SDK classes. Future projects can simply be pointed at the library which you have just created.
  8. Now switch to the Javadoc tab, and click its Add ZIP/Folder button, and add hme-javadoc.zip file found in the doc directory, so Javadoc comments will be visible for TiVo SDK classes Future projects can simply be pointed at the library which you have just created.
  9. Click the Add Library at the bottom of the Add Library dialog button to add the new TiVo library to your project. Click OK to close the Project Properties dialog.
  10. Now that all the dialogs are closed, you should be looking at the Main class that was generated by the New Project Wizard. Change the superclass to be Application. Press Alt-Shift-F (Ctrl-Shift-F on Macintosh) to auto-import com.tivo.hme.sdk.Application, the superclass.
  11. Insert the following code into the Main class (don't delete the main (String[] args) method!):
        protected void init(Context context) {
            root.setResource(createText("default-36-bold.font",
                Color.white, "Hello from an application!"));
        }
    
  12. Now just insert the following line in the existing main (String[] args) method:
        Simulator.main(new String[] {Main.class.getName()});
    
    Your complete class should look as follows:
    /*
     * Main.java
     *
     * Created on March 22, 2005, 2:46 PM
     */
    package tivotest;
    import com.tivo.hme.sdk.Application;
    import com.tivo.hme.sim.Simulator;
    import java.awt.Color;
    /**
     *
     * @author Brian Leonard
     */
    public class Main extends Application {
    
        /** Creates a new instance of Main */
        public Main() {
        }
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            Simulator.main(new String[] {Main.class.getName()});
        }
    
         protected void init(Context context) {
            root.setResource(createText("default-36-bold.font",
                Color.white, "Hello from an application!"));
        }
    
    }
    
Press F6 to run the app, press F5 to debug it.

For anybody interested, they appear to be running a contest.


↑返回目录
前一篇: Developing and Building Project GlassFish with NetBeans
后一篇: Developing for the SavaJe Mobile Platform