NBDemoPlatform

Step Onto Our Platform (50 Minutes)

Contents


Overview

This presentation is part of the NetBeans Day World Tour. It's a presentation/demo of the features in the NetBeans IDE that support NetBeans Module Development. Slides are available here. See also NetBeans Platform.


Setup

  • Install NB 5.0 (or newer)
  • Install the API Documentation module from the Update Center.
  • Download the NetBeans source and add it to the NetBeans Platform Manager.
  • Run NetBeans with the following option to supress any errors that may unexpectedly pop up: -J-DErrorManager.minimum=66000
  • Set --fontsize 14, which makes everything more readable for your audience
  • Before starting the IDE:
  • Delete the existing feedreader-suite project (if exists)
  • Remove the MDR cache and log file (this just helps ensure it's not corrupt)
  • Uninstall the GoogleToolbar module from the development IDE.
  • Delete the GoogleToolbar and GoogleToolbarSample projects (if exist)
  • Test adding the URLDisplayer module dependancy (the filter sometimes takes a long time to execute - hopefully an index is being built)
  • Download jfugue.jar (for the alternative platform demo).

Demo Steps

NetBeans Platform

Feed Reader (10 Minutes)

  1. Start the Platform
  • Show the menus and options dialog
  • Show the memory graph (to prove how lightweight it is)
  1. Create the FeedReader sample project
  2. Review the FeedReader Project Structure
  • It's actually 5 projects
  • Feed Reader Application is the Module Suite Project. Review its properties (Turn off mobility it's checked)
  • FeedReader is the module project. Review its properties, especially the Libraries (Module Dependencies)
  • jdom, rome & rome-fetcher are Library Wrapper Module Projects. Show how rome-fetcher is dependent on rome and rome is dependent on jdom.
  1. Run the Feed Reader Application
  • Add a couple of your favorite feeds (planetnetbeans.org is always a good choice)
  1. Build and Run it as a JNLP Application
  2. Create a HTML page to launch the Feed Reader JNLP Application
  • Switch to the Files tab
  • Open the Feed Reader Application's dist > jnlp > local directory
  • Show the generated JNLP file
  • Add a new HTML file to this directory, FeedReader
  • Add the following html <a href="master.jnlp">Launch Feed Reader Application</a> and save the file.
  • Right-click the new FeedReader.html and choose View
  • Launch the Feed Reader from the browser link.

Music Composer (15 Minutes)
This is an alternative platform demo where you create an application from scratch.

Show the nbjfugesupport Java.net project.

  1. CVS checkout from java.net:
  • CVS Root: :pserver:<username>@cvs.dev.java.net:/cvs
  • Module: nbjfuguesupport
  1. Open and run the project from NetBeans. Create a new composition and lay down some notes. Show the JFugue Commands tab, as this is the notation will will use in our simple version of the application.
  2. Close the 3 project files. Say, let's create this project from scratch (albeit, a simplier version).

The Module Suite Project

  1. Create a Module Suite named MusicSuite
  2. Open the project properties and uncheck all libraries but the platform
  3. Run the application and show the NetBeans Platform.

The Module Project
The Module Project contains our application's logic.

  1. Create a Module Project named Player
  2. Add a new Window Component.
  • Position it in the editor tab and open on application start.
  • Use Player for the Class Name Prefix and add the Image:eigth-note-16_NBDemoPlatform.png (eigth-note-16_NBDemoPlatform.png) icon.
  1. To the open PlayerTopComponent, add a JToolBar with 2 buttons, Play and Save. Below the JToolBar, add a JTextArea. Your simple form should look as follows:

Image:Player_NBDemoPlatform.png

  1. Set the font of the JTextArea to Veranda 24 Plain.
   We're ready to write code.

The Library Wrapper Module Project
Our Player's going to use the JFugue library to do all the heavy lifting. We incorporate this library into our project by using a Library Wrapper Module Project.

  1. Create a Library Wrapper Module Project for JFugue named JFugue

Coding the Player

  1. Add the JFugue module as a dependency to the Player project (project properties)
  2. Switch to the source view and add the following static initializer Note, to see the JFugue library's Javadoc, you have to add JFugue to the Library Manager, using the jfugue.jar file that was copied to the JFugue Library Wrapper Module Project. See issue 66275:
   private static Player player = new Player();
  1. Switch back to Design mode and set the actionPerformed method of the Play button to the following:
        Pattern pattern = new Pattern();
        pattern.add(jTextArea1.getText());       
        player.play(pattern);
  1. Set the Save actionPerformed method to the following:
        Pattern pattern = new Pattern();
        pattern.add(jTextArea1.getText());
        player.save(pattern, "MyNotes.midi");

Run

  1. Run the MusicSuite
  2. Paste the following code into the text area and hit play.
      C5q D5q E5q C5q I[[Cello | Cello]] E5q F5q G5h I[[Trumpet | Trumpet]] G5i A5i G5i F5i E5q C5q I[Piano] 5q G4q C5h
  1. Click Save.
  2. Browse to the file on disk (in the MusicSuite project folder) and play it.

Zip Distribution

  1. Open up the MusicSuite project's properties and change the Application to Create a Standalone Application. At this time, there's no point in supplying an Aplication Icon because the generated execuable doesn't really use it (Issue 64312). Also, replace the default NetBeans Platform splash screen with the following:
   Image:splash_NBDemoPlatform.gif
  1. Right-click the MusicSuite project and select "Build ZIP Distribution"
  2. Browse the the MusicSuite's dist directory and extract musicsuite.zip.
  3. Browse to the build directory and launch the executable.

Java Web Start

  1. Run JNLP Application (this is important, as a simple build will not generate the files in the dist directory used next).
  2. Create a HTML page to launch the MusicSuite JNLP Application
  • Switch to the Files tab
  • Open the MusicSuite Application's dist > jnlp > local directory
  • Show the generated master.jnlp file
  • Add a new HTML file to this directory, MusicSuite
  • Add the following html <a href="master.jnlp">Launch Music Composer Application</a> and save the file.
  • Right-click the new MusicSuite.html and choose View
  • Launch the Music Suite from the browser link.

NetBeans Module Development - Google Toolbar

Create a New Module
In this tutorial, we'll add a Google search bar to the IDE's toolbar. This demo script is based on the NetBeans Google Toolbar Module Tutorial.

  1. Create a new Module Project named GoogleToolbar
  2. Add a new Action to the project
  • Always Enabled (CallableSystemAction)
  • Category: Edit
  • Uncheck Globel Menu Item
  • Check Globel Toolbar Button
  • Toolbar: Edit
  • Position: Find... - HERE
  • Class Name: GoogleAction
  • Display Name: Google Action
  • Icon: Any image - it's just a place holder. You can use the 8th note (Image:eigth-note-16_NBDemoPlatform.png) from above
  1. Create a new JPanel named GoogleJPanel
  • Add a label (Google) and a JTextField. Your completed form should look as follows:
   Image:GoogleToolbar_NBDemoPlatform.png
  1. In the code we write to execute the Google search, we're going to take advantage of a NetBeans API class, URLDisplayer. Let's first add the library that contains this class to our project.
  • Open the project properties and choose Add
  • Type URLDisplayer into the Filter and select UI Utilities API
  1. On the GoogleJPanel, right-click the text box and select Events > Key > KeyTyped, which will open the source editor and add this event.
  2. Add the following code. Show code completion and Javadoc for HtmlBrowser (Javadoc doesn't appear for URLDisplayer - because it's an inner class?) Also use "Surround With try-catch" instead of coding it.
     private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {                                    
             if (evt.getKeyCar()==evt.VK_ENTER){
                 // do the search
                 try{
                     HtmlBrowser.URLDisplayer.getDefault().showURL (new URL( "http://www.google.com/search?hl=en&q="+jTextField1.getText()+"&btnG=Google+Search"));
                 } catch (MalformedURLException ex){
                     ex.printStackTrace();
                 }
             }
         }
  1. Override the getToolbarPresenter() method in the GoogleAction class (use code completion) to return the GooglePanel
    public java.awt.Component getToolbarPresenter() {
        return new GoogleJPanel();
    }
  • Test (run) the new module.

Show the Module Manager

  • Test run the new module in the Development IDE.
  • Show the Module Manager. Show how it can be dynamically activated and deactivated, then uninstall GoogleToolbar module.

Create an NBM

  • Create an NBM and use the update manager to install it.

Create a Sample Project based on the Google Toolbar

  1. Create a new Module Project named GoogleToolbarSample
  2. Add a new Project Template and select GoogleToolbar as the Project
  • Template Name: GoogleToolbarSample
  • Display Name: Google Toolbar Sample
  • Category: Samples | NetBeans Plug-in Modules
  1. Install in Target Platform
  2. Create a new project from the Google sample
  3. Install in Target Platform

NetBeans Module Development - Google Code Search

As an alternative to the Google Toolbar. The steps are spelled out in Geertjan's blog.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo