blob: a86a06b478df3607979fa73826921a69e2491541 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= NetBeans Platform Quick Start Using Maven
:jbake-type: platform_tutorial
:jbake-tags: tutorials
:jbake-status: published
:syntax: true
:source-highlighter: pygments
:toc: left
:toc-title:
:icons: font
:experimental:
:description: NetBeans Platform Quick Start Using Maven - Apache NetBeans
:keywords: Apache NetBeans Platform, Platform Tutorials, NetBeans Platform Quick Start Using Maven
Welcome to the link:https://netbeans.apache.org/platform/[*NetBeans Platform*]!
This document is a quick demonstration of how to create a simple NetBeans Platform application and module and use Maven for the build framework. In this document you will use Maven archetypes to create the NetBeans Platform application and module. You will use the Swing UI toolkit and "Matisse" GUI Builder to create a window component in the module. The modular aspect of the NetBeans Platform enables you to develop and expand the functionality of your application simply by adding new modules.
This document is based on the Ant-based link:nbm-quick-start.html[NetBeans Platform Quick Start for NetBeans Platform]. and illustrates some of the differences between using Ant and Maven to develop NetBeans Platform applications. After you understand how Maven is different from Ant, you can easily proceed through other tutorials on the link:https://netbeans.apache.org/kb/docs/platform.html[NetBeans Platform Learning Trail].
If you are using NetBeans IDE 6.8, see the link:68/nbm-maven-quickstart.html[Quick Start for NetBeans Platform 6.8 Using Maven].
If you are new to the NetBeans Platform, you might want to watch the screencast series link:https://netbeans.apache.org/tutorials/nbm-10-top-apis.html[Top 10 NetBeans APIs].
NOTE: You do not need to download a separate version of the NetBeans Platform to develop applications for the NetBeans Platform. Typically, you develop the applications and modules in the NetBeans IDE and then only include the modules that are necessary to run the NetBeans Platform and your application.
Before starting this tutorial you may want to familiarize yourself with the following documentation.
* link:http://wiki.netbeans.org/MavenBestPractices[Best Practices for Apache Maven in NetBeans 6.x]
* link:http://www.sonatype.com/books/maven-book/reference/introduction.html[Chapter 1. Introducing Apache Maven] (from link:http://www.sonatype.com/books/maven-book/reference/public-book.html[Maven: The Definitive Guide])
* link:https://netbeans.apache.org/kb/docs/java/gui-functionality.html[Introduction to GUI Building]
== Configuring Maven
If this is your first Maven project you will want to check the Maven configuration settings in the Options window. To complete this tutorial you must have Maven installed on your local system. You can download the installer from the link:http://maven.apache.org/[Maven site].
[start=1]
1. Select the Miscellaneous category in the Options window and click the Maven tab.
[start=2]
1. Specify the location of your local Maven installation (requires 2.0.9 or newer).
[start=3]
1. Check that the location of the local Maven repository is correct.
[start=4]
1. Click OK.
In most cases, if your Maven configuration is typical the information in the Options window should already be correct.
*Note.* Maven support is activated as part of the Java SE feature set. If the Maven tab is not available in the Options window, confirm that Java SE is activated by creating a Java application.
The IDE uses Maven SCM to checkout Maven artifacts. You might want to check that any clients necessary for checking out sources are installed on your local machine and configured correctly.
For details on Maven SCM, see the link:http://maven.apache.org/scm/index.html[Maven SCM page].
=== Viewing the Maven Repositories
The artifacts that are used by Maven to build all your projects are stored in your local Maven repository. When an artifact is declared as a project dependency, the artifact is downloaded to your local repository from one of the registered remote repositories.
The NetBeans repository and several well-known indexed Maven repositories are registered and listed in the Repository Browser window by default. The NetBeans repository contains most of the public artifacts necessary for you to build your project. You can use the Maven Repository Browser to view the contents of your local and remote repositories. You can expand the Local Repository node to see the artifacts that are present locally. The artifacts listed under the NetBeans repository nodes can be added as project dependencies, but not all of them are present locally. They are only added to the Local Repository when they are declared as project dependencies.
To open the Maven Repository Browser:
* Choose Window > Other > Maven Repository Browser from the main menu.
image::images/maven-quickstart68_maven-nbm-netbeans-repo.png[title="Screenshot of Maven Repository Browser"]
When your cursor is over an artifact, the IDE displays a tooltip with the artifact's coordinates. You can view additional details about an artifact by double-clicking the artifact's JAR file in the browser.
You can search for an artifact by clicking the Find button in the toolbar of the Maven Repository Browser or by using the Quicksearch textfield in the main toolbar.
For more about managing Maven classpath dependencies and working with Maven repositories in the IDE, see the link:http://wiki.netbeans.org/MavenBestPractices#Dependency_management[Dependency Management] section of link:http://wiki.netbeans.org/MavenBestPractices[Best Practices for Apache Maven in NetBeans 6.x].
To see a demonstration of using the Artifact Viewer, see the link:https://netbeans.apache.org/kb/docs/java/maven-dependencies-screencast.html[ Working with Maven Dependencies] screencast.
== Creating the NetBeans Platform Application Project
In this section you use the New Project wizard to create a NetBeans Application from a Maven archetype. The wizard will create the Maven module projects that you need to develop an application on the NetBeans Platform. The wizard also provides the option of creating a NetBeans module in the application project, but in this tutorial you will create each module individually.
=== Creating the Project
Perform the following steps to create the NetBeans Platform application using the New Project wizard.
[start=1]
1. Choose File > New Project (Ctrl-Shift-N) to open the New Project wizard.
[start=2]
1. Select Maven NetBeans Application from the Maven category. Click Next.
[start=3]
1. Type *MavenPlatformWordApp* for the Project Name and set the Project Location. Click Finish.
image::images/maven-quickstart_maven-newproject.png[title="Screenshot of New Project wizard"]
*Note.* If this is your first NetBeans Platform application using Maven, it can take some time to create the projects because the IDE needs to download any necessary artifacts from the NetBeans repository.
When you click Finish, by default the IDE creates the following Maven project types.
* *NetBeans Platform Application.* This project is a container project for the Platform application and lists the modules to include and the location of the project's repositories. This project does not contain any sources. The IDE generates the modules containing the sources and resources in sub-directories of this project.
* *NetBeans Platform based application.* This project specifies the artifacts (sources) needed for compiling the application. The required dependencies (IDE artifacts, module artifacts) are specified in the ``pom.xml`` file of the project. If you expand the Libraries node you can see the libraries required for the NetBeans Platform application.
* *Platform application branding resources.* This project contains the resources used for branding the application.
For all Maven projects, the ``pom.xml`` file (POM) is located under the Project Files node in the Projects window. If you look at the POM for the NetBeans Platform Application project, you can see that the two other modules created by the wizard are listed as modules in the application.
[source,xml]
----
<modules>
<module>branding</module>
<module>application</module>
</modules>
----
=== Modifying the Branding Elements
The branding module specifies the branding resources that are used when building the Platform application. The branding dialog enables you to easily modify the branding properties of the application to change the name, splash screen and the values of text elements.
When you create the NetBeans Platform application from the archetype, the default name for the application is the artifactId of the application. In this exercise you will use the branding wizard to modify the name of the application and replace the default image for the splash screen.
*Note.* The IDE needs to build the branding module before you can modify the branding resources.
[start=1]
1. Right-click the *Platform application branding resources* module and choose Branding.
[start=2]
1. In the Basic tab, modify the Application Title to *My Maven Platform Word App*.
image::images/maven-quickstart_maven-branding1.png[title="Screenshot of New Project wizard"]
[start=3]
1. Click the Splash Screen tab and click the Browse button next to the default splash screen image to locate a different image. Click OK.
You can copy the image below to your local system and specify the image as the splash screen in the Branding dialog.
image::images/maven-quickstart68_splash.gif[title="Example of default splash image"]
== Creating the MavenWordEngine Module
In this section you will create a new module named MavenWordEngine. You will then modify the module to add a window component and a button and text area.
=== Creating the Module
In this exercise you will create a new module project in the same directory that contains the branding module and application module.
[start=1]
1. Choose File > New Project from the main menu.
[start=2]
1. Select Maven NetBeans Module from the Maven category. Click Next.
[start=3]
1. Type *MavenWordEngine* as the Project Name.
[start=4]
1. Click Browse and locate the MavenPlatformWordApp directory as the Project Location. Click Finish.
image::images/maven-quickstart_maven-wizard-project-location.png[title="Screenshot of New Project wizard"]
If you look at the POM for the MavenWordEngine module you see that the ``artifactId`` of the project is *MavenWordEngine*.
[source,xml]
----
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>MavenPlatformWordApp</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany</groupId>
<artifactId>*MavenWordEngine*</artifactId>
<packaging>nbm</packaging>
<version>1.0-SNAPSHOT</version>
<name>MavenWordEngine NetBeans Module</name>
----
To build a NetBeans module you need to use the ``nbm-maven-plugin`` . If you look at the POM for the module, you can see that the IDE automatically specified ``nbm`` for the ``packaging`` and that the *nbm-maven-plugin* is specified as a build plugin.
[source,xml]
----
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>*nbm-maven-plugin*</artifactId>
<version>3.2-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
----
If you look at the POM for the NetBeans Platform Application, you can see that *MavenWordEngine* was added to the list of the modules in the application.
[source,xml]
----
<modules>
<module>branding</module>
<module>application</module>
<module>*MavenWordEngine*</module>
</modules>
----
=== Making the Module a Dependency of MavenPlatformWordApp
In this exercise you will declare the MavenWordEngine module as a dependency of the NetBeans Platform based application by adding the dependency in the POM. The POM for the application declares the following dependencies.
[source,xml]
----
<dependencies>
<dependency>
<groupId>org.netbeans.cluster</groupId>
<artifactId>platform</artifactId>
<version>${netbeans.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>branding</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
----
If you expand the Libraries node for the NetBeans Platform based application you can see that there is a dependency on the branding module and on some other libraries that are dependencies of the cluster required to build the application.
image::images/maven-quickstart_maven-projects-libraries.png[title="Screenshot of Add Dependency dialog"]
You can expand the list of non-classpath dependencies to see the full list of dependencies.
To add the dependency to the POM, you can edit the POM directly in the editor or by opening the Add Dependency dialog box from the Projects window.
[start=1]
1. Expand the *MavenPlatformWordApp - NetBeans Platform based application* in the Projects window.
[start=2]
1. Right-click the Libraries node and choose Add Dependency.
[start=3]
1. Click the Open Projects tab and select *MavenWordEngine*. Click OK.
image::images/maven-quickstart_maven-add-dependency1.png[title="Screenshot of Add Dependency dialog"]
*Note.* The new project will appear in the dialog after the IDE finishes scanning and updating indexes.
If you expand the Libraries node of MavenPlatformWordApp in the Projects window, you can see that MavenWordEngine is now listed as a dependency.
=== Adding a Window Component to the Module
In this exercise you will use a wizard to add a Window Component to the MavenWordEngine module.
[start=1]
1. Right-click *MavenWordEngine NetBeans Module* in the Projects window and choose New > Other to open the New File wizard.
[start=2]
1. Select Window in the Module Development category. Click Next.
[start=3]
1. Select *output* in the Window Position dropdown list. Click Next.
image::images/maven-quickstart_maven-new-window.png[title="Screenshot of window component page in New File wizard"]
[start=4]
1. Type *Text* in the Class Name Prefix field. Click Finish.
The wizard displays a list of the files that will be created and the files that will be modified.
When you click Finish, in the Projects window you can see that the IDE generated the class ``TextTopComponent.java`` in ``com.mycompany.mavenwordengine`` under Source Packages. The IDE also generated additional resource files in ``com.mycompany.mavenwordengine`` under Other Sources. In this exercise you will only edit ``TextTopComponent.java`` .
You can view the structure of the project in the Files window. To compile a Maven project, only source files can be located under Source Packages ( ``src/main/java`` directory in the Files window). Other resources (e.g., XML files) need to be located under Other Sources ( ``src/main/resources`` directory in the Files window).
=== Modifying the Window Component
In this exercise you will add a text area and a button to the window component. You will then modify the method invoked by the button to change the letters in the text area to upper case letters.
[start=1]
1. Click the Design tab of ``TextTopComponent.java`` in the editor.
[start=2]
1. Drag and drop a button and a text area from the Palette onto the window.
[start=3]
1. Right-click the text area and choose Change Variable Name, and then type *text* as the name. You will use the name when accessing the component from your code.
[start=4]
1. Set the text of the button to "*Filter!*".
image::images/maven-quickstart68_maven-nbm-textopcomponent.png[title="Screenshot of window component page in New File wizard"]
[start=5]
1. Double-click the Filter! button element in the Design view to open the event handler method for the button in the source code editor. The method is created automatically when you double-click the button element.
[start=6]
1. Modify the body of the method to add the following code. Save your changes.
[source,java]
----
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
*String s = text.getText();
s = s.toUpperCase();
text.setText(s);*
}
----
You can use the code completion in the editor to help you type the code.
If you want to test that your application is working correctly, you can right-click the project node of the *MavenPlatformWordApp NetBeans Platform based application* and choose Build with Dependencies.
The default action mapped to Build with Dependencies is to build the project using the Reactor plugin. When you build a project using the Reactor plugin, the dependencies of the sub-projects are built before the containing project is built. The Output window displays the build order.
image::images/maven-quickstart_maven-buildwithdependencies1.png[title="Screenshot of Reactor build order in Output window"]
The results of the build are also displayed in the Output window.
image::images/maven-quickstart_maven-buildwithdependencies2.png[title="Screenshot of successful Reactor build in Output window"]
If you look at the Projects window, you will see that the projects no longer have badges because the artifacts of the required dependencies are now available in the Local repository under the ``com.mycompany`` node.
image::images/maven-quickstart_maven-localrepo.png[title="Screenshot of Local repository"]
To run the project, right-click the project node of the *MavenPlatformWordApp NetBeans Platform based application* and choose Run. After the application launches, you can test the application by performing the following steps.
[start=1]
1. Choose Window > Text from the main menu of the platform application to open the Text window.
[start=2]
1. Type some lower case letters in the text area and click Filter!
[start=3]
1. Quit the Maven Platform Word App.
When you click Filter!, the letters that you typed are changed to upper case and displayed in the text area.
== Creating the TextFilter Module
In this exercise you will create a module named *TextFilter* and add the module as a dependency to the application. The TextFilter module will provide a service and only contain an interface. You can then access the service from your other modules by using a lookup.
=== Creating the Module
In this exercise you will perform the following steps to create the TextFilter module.
[start=1]
1. Choose File > New Project (Ctrl-Shift-N).
[start=2]
1. Select the Maven NetBeans Module archetype from the Maven category. Click Next.
[start=3]
1. Type *TextFilter* for the Project Name.
[start=4]
1. Click Browse to set the Project Location and locate the MavenPlatformWordApp directory. Click Finish.
When you click Finish, the IDE creates the module and opens the module project *TextFilter NetBeans Module* in the Projects window.
The IDE modifies ``pom.xml`` of the POM project MavenPlatformWordApp - NetBeans Platform Application to add the new module to the list of modules to include in the project.
[source,xml]
----
<modules>
<module>branding</module>
<module>application</module>
<module>MavenWordEngine</module>
<module>TextFilter</module>
</modules>
----
After you create the module you need to add the module as a dependency of the application.
=== Adding the TextFilter Module as a Dependency of MavenPlatformWordApp
In this exercise you add the TextFilter module as a dependency of the MavenPlatformWordApp NetBeans Platform based application.
[start=1]
1. Right-click the Libraries node of the *MavenPlatformWordApp - NetBeans Platform based application* project and choose Add Dependency.
[start=2]
1. Click the Open Projects tab in the Add Dependency dialog.
[start=3]
1. Select the *TextFilter NetBeans Module* module. Click OK.
When you click OK, the IDE adds the module as a dependency of the project. If you expand the Libraries node, you can see that the module is added to the list of dependencies. In the POM for *MavenPlatformWordApp - NetBeans Platform based application*, you can see that the IDE added the following lines inside the ``dependencies`` element.
[source,xml]
----
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>TextFilter</artifactId>
<version>${project.version}</version>
</dependency>
----
=== Adding an Interface to the TextFilter Module
In this exercise you will add a simple interface to the TextFilter module.
[start=1]
1. Right-click the *TextFilter NetBeans Module* and choose New > Java Interface.
[start=2]
1. Type *TextFilter* as the Class Name.
[start=3]
1. Select *com.mycompany.textfilter* in the Package dropdown list. Click Finish.
[start=4]
1. Modify the class to add the following code. Save your changes.
[source,java]
----
package com.mycompany.textfilter;
public interface TextFilter {
*public String process(String s);*
}
----
=== Making the TextFilter Module Public
In this exercise you will make the contents of the ``com.mycompany.textfilter`` package public so that other modules can access the methods. To declare a package as public, you modify the ``configuration`` element of ``nbm-maven-plugin`` in the POM to specify the packages that are exported as public by the plugin. You can make the changes to the POM in the editor or by selecting the packages to be made public in the project's Properties dialog box.
[start=1]
1. Right-click the *TextFilter NetBeans Module* and choose Properties.
[start=2]
1. Select the Public Packages category in the Project Properties dialog.
[start=3]
1. Select the *com.mycompany.textfilter* package. Click OK.
image::images/maven-quickstart_maven-public-packages.png[title="Screenshot of Properties dialog"]
When you click OK, the IDE modifies the project POM to modify the ``configuration`` element of the ``nbm-maven-plugin`` artifact to add the following entries.
[source,xml]
----
<publicPackages>
<publicPackage>com.mycompany.textfilter</publicPackage>
</publicPackages>
----
The POM entry now contains the following entries.
[source,xml]
----
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>3.2</version>
<extensions>true</extensions>
<configuration>
<publicPackages>
<publicPackage>com.mycompany.textfilter</publicPackage>
</publicPackages>
</configuration>
</plugin>
----
For more information, see link:http://bits.netbeans.org/mavenutilities/nbm-maven-plugin/manifest-mojo.html#publicPackages[nbm-maven-plugin manifest]
== Creating the MyFilter Module
In this exercise you will create the module *MyFilter* and add the module as a dependency of TextFilter. You can then call methods in MyFilter by looking up the TextFilter service.
=== Creating the Module
In this exercise you will create a module named *MyFilter*. To create the module, you will perform the same steps that you performed when you created the TextFilter module.
[start=1]
1. Choose File > New Project (Ctrl-Shift-N).
[start=2]
1. Select Maven NetBeans Module from the Maven category. Click Next.
[start=3]
1. Type *MyFilter* for the Project Name.
[start=4]
1. Click Browse to set the Project Location and locate the *MavenPlatformWordApp* directory. Click Finish.
[start=5]
1. Add the MyFilter module as a dependency of the *MavenPlatformWordApp - NetBeans Platform based application* project.
=== Adding the TextFilter Module as a Dependency
In this exercise you add the TextFilter module as a dependency of the MyFilter module.
[start=1]
1. Right-click the Libraries node of the *MyFilter* project and choose Add Dependency.
[start=2]
1. Click the Open Projects tab in the Add Dependency dialog.
[start=3]
1. Select the *TextFilter* module. Click OK.
=== Modifying the MyFilter Module
In this exercise you will add a Java class with a single method that is named ``process`` that converts a string to upper case. You will also specify that the class will implement the TextFilter interface. You will use an ``@ServiceProvider`` annotation to specify that TextFilter is a service that will be registered at compile time.
[start=1]
1. Right-click the *MyFilter* module and choose New > Java Class.
[start=2]
1. Type *UpperCaseFilter* as the Class Name.
[start=3]
1. Select *com.mycompany.myfilter* in the Package dropdown list. Click Finish.
[start=4]
1. Modify the class to add the following code. Save your changes.
[source,java]
----
package com.mycompany.myfilter;
import com.mycompany.textfilter.TextFilter;
import org.openide.util.lookup.ServiceProvider;
*@ServiceProvider(service=TextFilter.class)*
public class UpperCaseFilter *implements TextFilter {
public String process(String s) {
return s.toUpperCase();
}*
}
----
Notice how the annotation is used to specify the Service Provider. For more about the ``@ServiceProvider`` annotation and the behavior of the ServiceLoader mechanism in JDK 6, see the Utilities API documentation.
=== Modifying the MavenWordEngine Module
In this exercise you will modify the event handler in the Text window component to use a lookup to call the TextFilter interface and access the method in MyFilter. Before adding the code to the event handler you need to declare a dependency on the TextFilter module.
[start=1]
1. Right-click the Libraries node of the *MavenWordEngine* module and add a dependency on the TextFilter module.
[start=2]
1. Expand the Source Packages of the *MavenWordEngine* module and open ``TextTopComponent`` in the source editor.
[start=3]
1. Modify the ``jButton1ActionPerformed`` button handler method to add the following code. Save your changes.
[source,java]
----
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String s = text.getText();
*TextFilter filter = Lookup.getDefault().lookup(TextFilter.class);
if (filter != null) {
s = filter.process(s);
}*
text.setText(s);
}
----
You can use code completion to help you with the code.
At this point you can check your application to see if it works correctly. Next you will add a new window component that will display a history of the text that you processed using the filter.
== Adding LookupListener and InstanceContent to the Text window component
In this exercise you add a listener and a field to store the contents of the text area when the "Filter!" button is clicked.
[start=1]
1. In the *MavenWordEngine* module, add the ``InstanceContent`` object and modify the constructor of ``TextTopComponent`` by adding the following code.
[source,java]
----
public final class TextTopComponent extends TopComponent {
*private InstanceContent content;*
public TextTopComponent() {
initComponents();
setName(NbBundle.getMessage(TextTopComponent.class, "CTL_TextTopComponent"));
setToolTipText(NbBundle.getMessage(TextTopComponent.class, "HINT_TextTopComponent"));
// setIcon(Utilities.loadImage(ICON_PATH, true));
*content = new InstanceContent();
associateLookup(new AbstractLookup(content));*
}
----
[start=2]
1. Modify the ``jButton1ActionPerformed`` method to add the old value of the text to the ``InstanceContent`` object when the button is clicked.
[source,java]
----
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String s = text.getText();
TextFilter filter = Lookup.getDefault().lookup(TextFilter.class);
if (filter != null) {
*content.add(s);*
s = filter.process(s);
}
text.setText(s);
}
----
== Creating the History Module
In this section you will create a module named *History* that will display the value of the ``InstanceContent`` . To create the module, you will perform the same steps that you performed when you created the TextFilter and MyFilter modules.
[start=1]
1. Choose File > New Project (Ctrl-Shift-N).
[start=2]
1. Select Maven NetBeans Module from the Maven category. Click Next.
[start=3]
1. Type *History* for the Project Name.
[start=4]
1. Click Browse to set the Project Location and locate the MavenPlatformWordApp directory. Click Finish.
[start=5]
1. Add the History module as a dependency of the *MavenPlatformWordApp - NetBeans Platform based application* project.
=== Creating a Window Component in the History Module
In this exercise you will use a wizard to add a window component to the module.
[start=1]
1. Right-click *History NetBeans Module* in the Projects window and choose New > Other to open the New File dialog.
[start=2]
1. Select Window in the Module Development category. Click Next.
[start=3]
1. Select *editor* in the Window Position dropdown list. Click Next.
[start=4]
1. Type *History* in the Class Name Prefix field. Click Finish.The wizard displays a list of the files that will be created and the files that will be modified.
=== Modifying the History Window Component
You will now add a text area element to the window component that will display the filtered strings.
[start=1]
1. Click the Design tab of ``HistoryTopComponent.java`` in the editor.
[start=2]
1. Drag and drop a text area from the Palette onto the window.
[start=3]
1. Right-click the text area and choose Change Variable Name, and then type *historyText* as the name.
[start=4]
1. Add the ``private`` field ``result`` and the following code to the constructor of the ``HistoryTopComponent`` so that it listens to the lookup of the String class of the current active window and displays all retrieved String objects in the text area.
[source,java]
----
*private Lookup.Result result;*
public HistoryTopComponent() {
initComponents();
...
*result = org.openide.util.Utilities.actionsGlobalContext().lookupResult(String.class);
result.addLookupListener(new LookupListener() {
public void resultChanged(LookupEvent e) {
historyText.setText(result.allInstances().toString());
}
});*
}
----
== Building and Running the Application
You can now test the application.
[start=1]
1. Right-click the project node of the *MavenPlatformWordApp NetBeans Platform based application* and choose Clean.
[start=2]
1. Right-click the project node of the *MavenPlatformWordApp NetBeans Platform based application* and choose Build with Dependencies.
[start=3]
1. Right-click the project node of the *MavenPlatformWordApp NetBeans Platform based application* and choose Run.
When you click Run, the IDE launches the NetBeans Platform application. You can open the History and Text windows from the Window menu.
image::images/maven-quickstart_maven-final-app.png[title="Screenshot of final NetBeans Platform application"]
When you type text in the Text window and click the Filter! button, the text is converted to upper case letters and the text is added to the content of the History window.
This quickstart demonstrated how creating a NetBeans Platform application using Maven is not very different from creating an application using Ant. The major difference is understanding how the Maven POM controls how the application is assembled. For more examples on how to build NetBeans Platform applications and modules, see the tutorials listed in the link:https://netbeans.apache.org/kb/docs/platform.html[NetBeans Platform Learning Trail].
link:http://netbeans.apache.org/community/mailing-lists.html[ Send Us Your Feedback]
 
== See Also
For more information about creating and developing applications, see the following resources.
* link:https://netbeans.apache.org/kb/docs/platform.html[NetBeans Platform Learning Trail]
* link:http://bits.netbeans.org/dev/javadoc/[NetBeans API Javadoc]
If you have any questions about the NetBeans Platform, feel free to write to the mailing list, dev@platform.netbeans.org, or view the link:https://mail-archives.apache.org/mod_mbox/netbeans-dev/[NetBeans Platform mailing list archive].