Drabo has posted 12 posts at DZone. View Full User Profile

Create your First ExtJS 4 Application with NetBeans IDE

07.06.2013
| 12353 views |
  • submit to reddit

This article shows you a quick start for setting up NetBeans IDE for ExtJS 4 application development.

ExtJS is a "Cross-Browser Rich Internet Application Framework". It is based on JavaScript and web standards that help developers build pretty applications supported by several browsers. You can find more information (http://www.sencha.com) about this framework.

I've found the HTML5 features in NetBeans to provide excellent support for building an ExtJS application, as shown below. 

Create an empty HTML5 project

The first thing to do is create an empty HTML5 project in NetBeans by following the tutorial on the official website, that is, Getting Started with HTML5 Applications . 

  • "New Project -> HTML/Javascript -> HTML5 Application"  and click on "Next"  button.
  • Give a name to your project ( I choosed TutoExtJS) and  click on "Finish" button .


Download ExtJs 4

In order to have the ExtJs 4 librairies, you need to download the framework on Sencha website (sencha ).

  • Unzip the file in a temporary directory  and rename it as you wish ( I renamed mine "ext").
  • Create a directory on your project  were you will upload the extjs librairies directory  :
  • Right-click on the node "Site Root"  ->  "New -> Other -> Folder" and give a name to the folder ( I gave  "js").
  • Copy the  extjs directory and paste into the  js node ( image below)


Write your application

Now we are on the way to write our first  ExtJs application based on NetBeans

1 - Create the index.html

The index.html file is created by default. We will just replace the content with the code below :

<!DOCTYPE html>
<html>
  <head>
    <title>Account Manager</title>
    <link rel="stylesheet" type="text/css" href="js/ext/resources/css/ext-all.css">
    <script type="text/javascript" src="js/ext/ext-all.js"></script>
    <script type="text/javascript" src="test.js"></script>
  </head>
  <body></body>
</html>

2 - Create the javascript file test.js

Right-click on the project node => New => Other => JavaScript file  and give a name ( in the tutorial I named it test.js).

Replace the content of the new file by the code below :

function createNetBeansWin() {
    var win  = new Ext.create('Ext.Window', {
        id : 'myWindow',
        title : 'My first ExtJs Window with NetBeans',
        width : 300,
        height : 150,
        layout : 'fit'
    }); 
    win.show();
}
Ext.onReady(createNetBeansWin);


Your application is ready. Just run the application by right-clicking on the project and  "Run".


Published at DZone with permission of its author, Drabo Constantin.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Sean Phillips replied on Fri, 2013/07/12 - 5:17pm

Nice Drabo.   Finally an article to convince my HTML5 coworkers to use NetBeans!

I'm not particular big on Web Development anymore but I recognize its strength.  An article like this makes me want to try it out through my beloved NetBeans.

Drabo Constantin replied on Tue, 2013/07/16 - 10:03am in response to: Sean Phillips

Thanks Phillips ! NetBeans is becoming strong, many surprises are coming, you should start adopting it.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.