
Search: 		
netbeans.org - go to homepage
cornercorner
FeaturesPluginsDocs & SupportCommunityPartners
HOME > Community > Projects > platform
NetBeans Platform
NetBeans Platform Quick Start

Welcome to the NetBeans Platform!

This tutorial provides a very simple and quick introduction to the NetBeans Platform workflow by walking you through the creation of a simple HTML Editor. Though simple, the HTML Editor you create will be very mature because it will reuse the infrastructure provided by the NetBeans Platform. For example, without any coding, your HTML Editor will have a mature window system. Once you are done with this tutorial, you will have a general understanding of how to create, build, and run applications on top of the NetBeans Platform.

After you finish this tutorial, you can move on to the NetBeans Platform learning trail. The learning trail provides comprehensive tutorials that highlight a wide range of NetBeans APIs for a variety of application types. If you do not want to do a "Hello World" application, you can skip this tutorial and jump straight to the learning trail.

Note: This document uses the NetBeans IDE 6.5 Release. If you are using an earlier version, see the 6.1 version of this document. If, instead of learning how to create a NetBeans Platform application, you would like to learn how to create a NetBeans plugin, see the NetBeans Plugin Quick Start.

Contents
Content on this page applies to NetBeans IDE 6.5

    * Generating the Skeleton Application
    * Tweaking the User Interface
    * Tweaking the Window Layout
    * Tweaking the Favorites Window
    * Running the Application
    * Distributing the Application
          o Distributing the HTML Editor via a ZIP File
          o Distributing the HTML Editor via the Shared NetBeans Web Start Repository

To follow this tutorial, you need the software and resources listed in the following table.
Software or Resource 	Version Required
NetBeans IDE 	version 6.5
Java Developer Kit (JDK) 	Version 6 or
version 5

Optionally, for troubleshooting purposes, you can download the completed sample and inspect the sources.

At the end of this tutorial, you will have an HTML Editor that looks like this:
Final HTML Editor

Note: Although this a very simple demo application, it is not a toy! It is a real program that supports easy editing of HTML pages, with features such as code completion, validation, and predefined HTML snippets.

The HTML Editor that you create in this tutorial is a rich-client application built "on top of the NetBeans Platform". What this means is that the core of the IDE, which is what the NetBeans Platform is, will be the base of your application. On top of the NetBeans Platform, you add the modules that you need and exclude the ones that the IDE needs but that your application doesn't. Here you see some of the IDE's modules, added to the NetBeans Platform, which is its base:
Structure of NetBeans Platform applications

Creating this HTML Editor means generating an application skeleton, excluding the modules and user interface items that you do not need, and then setting the Favorites window as the window that will open by default when the IDE starts. All of these activities are supported by user interface elements in the IDE.

You will see for yourself how simple and easy it is to build, or to be more precise, to assemble a full-featured application on top of the NetBeans Platform. At the end, you are shown how to make the final product easily downloadable and launchable using WebStart.

Note: Even though it is a separate product, there is no need to download the NetBeans Platform separately for purposes of this tutorial. You will develop the rich-client application in the IDE and then exclude the modules that are specific to the IDE but that are superfluous to you application.
Generating the Skeleton Application

When creating an application on the NetBeans Platform, the very first step is to create a NetBeans Platform Application project. The default NetBeans Platform Application project includes all the modules included in the NetBeans Platform as well as all the modules included in NetBeans IDE. Since we do not need all these modules, we will exclude those that we do not need.

   1. Using the New Project wizard (Ctrl-Shift-N), create a NetBeans Platform Application Project from the template in the NetBeans modules category, as shown below:

      New Project wizard

      Click Next and name the NetBeans Platform Application project "NetBeansHTMLEditor". Click Finish.
   2. Right-click the project node, choose Properties, and then make a few changes in the NetBeans Platform Application's Project Properties dialog box:

          * In the Build panel, click "Create Standalone Application", to specify that this is going to be a rich-client application on top of the NetBeans Platform.

            Make sure that you like the branding name for the executable and tweak the application title for the titlebar, as shown below:

            Application panel
          * In the Splash Screen panel, notice that you can provide the application's splash screen, and progress bar brandings, as shown below:

            Splash Screen panel

            Note: If you do not have a splash screen, use this one. 
   3.

      In the Libraries panel of the Project Properties dialog box, you see a list of "clusters". A cluster is a collection of related modules. The only clusters that need to be selected are gsf1, ide10 and platform9. Deselect all the other clusters. Now you need to enable and disable a number of modules, because only those specifically relevant to our HTML Editor should be selected. Whenever you select or deselect a module in the Libraries panel, an entry is added to the application's NetBeans Platform Config file. To speed up this process, we will simply paste the entries into that file. Close the Project Properties dialog box.

Now you have the subset of NetBeans modules that are relevant to your HTML Editor. However, even though you need the modules that you now have, you probably do not need all of the user interface elements that these modules give you. In the next sections, you tweak the user interface and customize the window layout specifically for the HTML Editor that you are creating.
Tweaking the User Interface

You can keep or reject as much of the user interface that your selected modules give you. For example, your HTML Editor probably does not need any or all of the items under the Tools menu. Similarly, maybe there are toolbars or toolbar buttons that you can do without. In this section, you prune the IDE's user interface until you are left with a subset that is useful to your specific rich-client application.

   1. Expand the NetBeans Platform Application project, right-click the Modules node and choose Add New, as shown below:

      This layer in context

      The New Project wizard (Ctrl-Shift-N) appears. Name the project BrandingModule, click Next.
   2. In the Code Name Base field, type org.netbeans.brandingmodule.
   3. Click "Generate XML Layer" and then click Finish.
   4. In the branding module, expand the layer.xml node. Two subnodes are exposed:

      Expanded XML layer file
   5. In the <this layer in context> node, the IDE shows you a merged view of all folders and files that all modules register in their layers. To exclude items, you can right-click them and choose 'Delete', as shown below:

      This layer in context

      The IDE then adds tags to the module's layer.xml file which, when the module is installed, hides the items that you have deleted. For example, by right-clicking within Menu Bar/Edit, you can remove menu items from the Edit menu that are not necessary for the HTML Editor. By doing this, you generate snippets such as the following in the layer.xml file:

      <folder name="Menu">
          <folder name="Edit">
              <file name="org-netbeans-modules-editor-MainMenuAction$StartMacroRecordingAction.instance_hidden"/>
              <file name="org-netbeans-modules-editor-MainMenuAction$StopMacroRecordingAction.instance_hidden"/>
          </folder>       
      </folder>

      The result of the above snippet is that the Start Macro Recording and Stop Macro Recording actions provided by another module are removed from the menu by your branding module. To show them again, simply delete the tags above from the layer.xml file.
   6.

      Use the approach described in the previous step to hide as many toolbars, toolbar buttons, menus, and menu items as you want.

      When you have completed this stage, look in the layer.xml file. When you do so, you should see something similar to the following, depending on the items that you have deleted:

Tweaking the Window Layout

By using the <this layer in context> node, you can not only delete existing items, but you can also change their content. For example, the HTML Editor works on HTML files, so in contrast to the regular IDE, which works with Java source files and projects as well, it makes sense to show the Favorites window in the initial layout.

The definition of the window layout is also described as files in layers, all stored under the Windows2 folder. The files in the Windows2 folder are pseudo-human readable XML files defined by the Window System APIs. They are quite complex but the good news is that, for purposes of our HTML Editor, it is not necessary to understand them fully, as shown below.

   1. In your branding module's <this layer in context> node, right-click the Windows2 node and choose Find, as shown below:

      Invoking the Find menu
   2. Search for an object named Favorites, ignoring the case. You will find two files:

      Finding the Favorites window

      The first file defines what the component is going to look like and how it gets created. As this does not need to be changed, there is no need to modify the file. The second is more interesting for your purposes, it contains the following:

      <tc-ref version="2.0">
          <module name="org.netbeans.modules.favorites/1" spec="1.1" />
          <tc-id id="favorites" />
          <state opened="false" />
      </tc-ref>

   3. Even though most of the XML is cryptic, there is one line which seems promising—without needing to read any kind of documentation, it seems likely that changing the false to true is going to make the component opened by default. Do so now.
   4. In a similar way you can change the following windows from their default open state to the state that you might want them to behave in the HTML Editor:
          * CommonPalette.wstcref. The Component Palete's open state is false. Change it to true.
          * projectTabLogical_tc.wstcref. The Projects window's open state is true. Change it to false.
          * projectTab_tc.wstcref. The Files window's open state is true. Change it to false.
          * runtime.wstcref. The Services window's open state is true. Change it to false. 

You should now see that your branding module contains several new files, one for each of the files that you changed. In effect, these files override the ones that you found in the previous steps, so that you have now provided the required information for overriding the window layout:

Overridden Favorites layout

Check that the layer.xml file now contains the following content. If it does not, copy and paste the content below into the layer.xml file.

Tweaking the Favorites Window

In the subfolders of a NetBeans Platform Application project's branding folder, which is visible in the Files window, you can override strings defined in the NetBeans sources. In this section, you will override strings that define labels used in the Favorites window. For example, we will change the "Favorites" label to "HTML Files", because we will use that window specifically for HTML files.

   1. Open the Files window and expand the NetBeans Platform Application project's branding folder.
   2. Create a new folder structure within branding/modules. (In the IDE, you can create folders by right-clicking a folder and then choosing New | Other and then choosing Folder from the Other category.) The new folder should be named org-netbeans-modules-favorites.jar. Within that folder, create a folder hierarchy of org/netbeans/modules/favorites. Within the final folder, i.e. favorites, create a new Bundle.properties file:

      Branding the Favorites window

      This folder structure and properties file matches the folder structure in the NetBeans sources that relate to the Favorites window.
   3. Add the strings shown in the screenshot below, to override the same strings defined in the matching properties file in the Favorites window sources:

      Branding the Favorites window

      To simplify this step, copy and paste the strings defined above:

      Favorites=HTML Files
      ACT_AddOnFavoritesNode=&Find HTML Files...
      ACT_Remove=&Remove from HTML Files List
      ACT_View=HTML Files
      ACT_Select=HTML Files
      ACT_Select_Main_Menu=Select in HTML Files List

      # JFileChooser
      CTL_DialogTitle=Add to HTML Files List
      CTL_ApproveButtonText=Add
      ERR_FileDoesNotExist={0} does not exist.
      ERR_FileDoesNotExistDlgTitle=Add to HTML Files List
      MSG_NodeNotFound=The document node could not be found in the HTML Files List.

Later, when you start up the application, you will see that the texts and labels in the Favorites window have changed to those listed above. This illustrates that you can take a component from the NetBeans Platform and then brand it to match your needs.
Running the Application

Running your application is as simple as right-clicking the project node and choosing a menu item.

   1. Right-click the application's project node and choose Clean and Build All.
   2. Right-click the application's project node and choose Run.
   3. After the application is deployed, you can right-click inside the Favorites window and choose a folder containing HTML files, and then open an HTML file, as shown below:

      Open HTML file 

You now have a complete, functioning, HTML Editor, which you created without typing a single line of Java code.
Distributing the Application

Choose one of two approaches for distributing your application. If you want to maintain as much control over your application as possible, you will use web start to distribute your application over the web. In this scenario, whenever you want to update the application, you will do so locally and let your end users know about the update, which they will automatically have available next time they start up your application over the web. Alternatively, distribute a ZIP file containing your application. The end users will then have the complete application locally available. You would then distribute updates and new features via the update mechanism, described below.
Distributing the Application via a ZIP File

To make your application extendable, you need to let your users install modules to enhance the application's functionality. To do so, you simply need to enable a few extra modules, which will bundle the Plugin Manager with your HTML Editor.

   1. Right-click the NetBeans Platform Application project and choose Properties. In the Project Properties dialog box, use the Libraries panel and select the Update Centers checkbox, as well as the Auto Update Services checkbox and the Auto Update UI checkbox that are highlighted below:

      Auto Update modules
   2. Right-click the application's project node and choose Clean and Build All.
   3. Run the application again and notice that you now have a new menu item, named "Plugins", under the Tools menu:

      Showing the Plugin Manager
   4. Choose the new Plugins menu item and install some plugins that are useful to your HTML Editor. Browse the Plugin Portal to find some suitable ones. This is also how your end users will update their local installation of your application.
   5.

      Right-click the application's project node and choose Build ZIP Distribution.
   6. In the dist folder (visible in the Files window), you should now be able to see a ZIP file that you can expand, to see its contents:

      Generated ZIP file

      Note: The application's launcher is created in the bin folder, as shown above. 


Distributing the HTML Editor via the Shared NetBeans Web Start Repository

Instead of distributing a ZIP file, let's prepare for a webstart distribution by finetuning the master.jnlp file that is generated the first time you start the application. Even though it does the job, it is not yet ready for distribution. At the very least, you need to change the information section to provide better descriptions and icons.

Another change to the standard JNLP infrastructure is the use of a shared JNLP repository on www.netbeans.org. By default, the JNLP application generated for a suite always contains all its modules as well as all the modules it depends on. This may be useful for intranet usage, but it is a bit less practical for wide internet use. When on the internet, it is much better if all the applications built on the NetBeans Platform refer to one repository of NetBeans modules, which means that such modules are shared and do not need to be downloaded more than once.

There is such a repository for NetBeans 6.1. It does not contain all the modules that NetBeans IDE has, but it contains enough to make non-IDE applications like our HTML Editor possible. To use the repository you only need to modify platform.properties by adding the correct URL:

# share the libraries from common repository on netbeans.org
# this URL is for release60 JNLP files:
jnlp.platform.codebase=http://www.netbeans.org/download/6_0/jnlp/

As soon as the application is started as a JNLP application, all its shared plug-in modules are going to be loaded from netbeans.org and shared with other applications doing the same.


Send Us Your Feedback

See Also

This concludes the NetBeans Platform Quick Start. This document has described how to create a plugin that adds a Google Search toolbar to the IDE. For more information about creating and developing applications on the NetBeans Platform, see the following resources:

    * Other Related Tutorials

    * NetBeans API Javadoc

	
Documentation

Overview

    * What's New in 6.5?
    * What's the Difference between NetBeans Platform and Eclipse RCP?
    * Customer Testimonials

Getting Started

    * NetBeans Plugin Quick Start
    * NetBeans Platform Quick Start
    * NetBeans Platform Developer FAQs
    * NetBeans APIs in a Nutshell
    * NetBeans API Javadoc
    * Latest NetBeans API Changes

All NetBeans Platform Docs
Training

Professional Training Courses

    * NetBeans Platform Certified Training


NetBeans Platform Books

    * Rich Client Programming: Plugging into the NetBeans Platform

All Books

Support

Professional Support Services

    * Sun Microsystems Support Plans for NetBeans IDE 

Community Forums and Resources

    * NetBeans Platform Developer FAQs
    * NetBeans Platform Mailing List 


corner corner
Shop   SiteMap   About Us   Contact   Legal  
By use of this website, you agree to the NetBeans Policies and Terms of Use
Companion
Projects: 		MySQL - Open Source Database Server  	GlassFish Community: an Open Source Application Server  	Open Solaris  	Open JDK: an Open SourceJDK  	Mobile & Embedded Community  	OpenOffice - The free and open productivity suite 	Open ESB - The Open Enterprise Service Bus 	Virtual Box - full virtualizer	 Sponsored by 
Sponsored by Sun Microsystems

