Sunday, March 30, 2008

Netbeans IDE: The Innovative and Complete IDE

Innovation is what can be the other name of Netbeans IDE6।1 , true to the fact as it says "The only IDE you need"।The notable features of the Netbeans IDE 6।1 can be found highlighted at Netbeans6।1Perhaps, the best thing about the IDE is that it gives us a chance to realize our new ideas by building plugins on to the Netbeans platform.We will therefore have a short view of how to make a simple GUI based parser.This makes use of a class of java.util package called the StringTokenizer class.
Pre-Requisites

Brief Idea about String Tokenizer
The processing of text often consists of parsing a formatted input string.Parsing is the division of the text into a set of discrete parts or tokens, which in a certain sequence can convey a semantic meaning.The StringTokenizer class provides the first step in the parsing process, often called the lexer(or lexical analyzer) or scanner. StringTokenizer class implements the Enumeration interface.

To use StringTokenizer , we specify an input string and a string that contains delimiters.Delimiters are characters that separate tokens.By default, whitespace characters:space,tab,newline and carriage return are considered delimiters.

Creating a NetBeans Plug-in Module Project

  1. Choose File > New Project. Under Categories, select NetBeans Plug-in Modules.

    NetBeans plug-in module support provides three project types:
    1. Module Project. Creates a template for a standalone plug-in module.

    2. Library Wrapper Module Project. Creates a plug-in module for an external JAR file required by one or more plug-in modules.

    3. Module Suite Project. Creates a template for a set of interdependent plug-in modules and library wrapper modules, which you want to deploy together.

  2. Select Module Project. Click Next.





  3. In the Name and Location panel, type Stokenizer in Project Name. Change the Project Location to any directory on your computer, such as C:\Documents and Settings\Samir Kumar Mishra. Leave the Standalone Module radio button and the Set as Main Project checkbox selected. Click Next. (Figure 2).















In the Basic Module Configuration panel, replace yourorghere in Code Name Base with myorg, so that the whole code name base is org.myorg.Stokenizer.Notice that the localizing bundle and the XML layer will be stored in the package org.myorg.Stokenizer. These files do the following:
Localizing Bundle. Specifies language-specific strings for internationalization.XML Layer. Registers items such as menus and toolbar buttons in the NetBeans System Filesystem.


  1. Click Finish. The IDE creates the Stokenizer project. The project contains all of your sources and project metadata, such as the project's Ant build script. The project opens in the IDE. You can view its logical structure in the Projects window (Ctrl-1) and its file structure in the Files window (Ctrl-2)
Using the Window Component Wizard
  1. Right click the project Stokenizer folder and select New->File/Folder
  2. In the New File wizard, choose NetBeans Module Development under Categories and Window Component under File Types. Click Next.



  3. In the Basic Settings panel of the New Window, check the option "Open On Application Start" and click Next.The place of its opening is kept "output " to default.

  4. In the Name, Icon, Location Panel, fill up the name as "Tokenizer" and click Finish.
  5. Your Project window will have some files generated like TokenizerAction.java , TokenizerTopComponent.java and some xml files. (Figure 2)



















  6. The TokenizerTopComponent.java has a source view and a design view.Using palette on the righthand side, just drag and drop components in to the design and resize it.


















  7. Right click on the jButton1 and choose Events, then Action, then ActionPerformed() so that the event listener is registered with the jButton1.



  8. Copy and paste the following code in the method jButton1ActionPerformed().This will come immediately after your selection of the event in the step 7.

String str1=jTextField1.getText();
String str2=jTextField2.getText();

StringTokenizer st= new StringTokenizer(str1,str2);

while(st.hasMoreTokens()) {
jTextArea1.append(st.nextToken()+"\n");
}

9. You will see an error in the line:
StringTokenizer st= new StringTokenizer(str1,str2);

10.Click on the "X"(cross) symbol at the left of the line.the line is now highlighted with a bulb symbol glowing. Click on the bulb.It will show an option to "add import java.util.StringTokenizer". Just click on that.This way Netbeans helps you to fix errors in your program

You could have also just pressed Alt+Shift+F to fix the necessary imports.
Press Ctrl+ Shift + F to reformat your code.

11.Right click on the Stokenizer project node and select the Install/Reload in Target Platform

12.Final out put will look like this in the place where the output window was:











Using the String Tokenizer Plug-In(just an example)

  1. Enter "Hello + Samir,;Minakshi,(krishna)*,Rama$,hari" as the Input String

  2. Enter the delimiters string as "+;()*$"

  3. Press the Button "Parse".

  4. The output will be Hello
    Samir,
    Minakshi,
    krishna
    ,Rama
    ,hari

  5. Note that we have deliberately left the comma(,) and therefore it appears.

In this way, we have built a plugin very easily into Netbeans platform.

4 comments:

Varun said...

Hi,

My name is Varun Nischal and I'm the NetBeans Community Docs Contribution Coordinator. Your blog entry would make a fantastic tutorial for our Community Docs wiki (http://wiki.netbeans.org/CommunityDocs).

Would you be willing to contribute it? If you need any help or have any questions, please contact me at nvarun@netbeans.org

I look forward to hearing from you.

Thanks,
Varun Nischal
http://nb-community-docs.blogspot.com/
--
"You must do the things you think you cannot do."

Ogma said...

Please, please use meaningful variable names, eg "delimiters" instead of "str2", "names" instead of "str1", "nameField" instead of "jTextField1", etc.

mak said...

Hi,
Your Tutorial works under netbeans ide 6.5

Masoud

milf said...

black mold exposureblack mold symptoms of exposurewrought iron garden gatesiron garden gates find them herefine thin hair hairstylessearch hair styles for fine thin hairnight vision binocularsbuy night vision binocularslipitor reactionslipitor allergic reactionsluxury beach resort in the philippines

afordable beach resorts in the philippineshomeopathy for eczema.baby eczema.save big with great mineral makeup bargainsmineral makeup wholesalersprodam iphone Apple prodam iphone prahacect iphone manualmanual for P 168 iphonefero 52 binocularsnight vision Fero 52 binocularsThe best night vision binoculars here

night vision binoculars bargainsfree photo albums computer programsfree software to make photo albumsfree tax formsprintable tax forms for free craftmatic air bedcraftmatic air bed adjustable info hereboyd air bedboyd night air bed lowest pricefind air beds in wisconsinbest air beds in wisconsincloud air beds

best cloud inflatable air bedssealy air beds portableportables air bedsrv luggage racksaluminum made rv luggage racksair bed raisedbest form raised air bedsbed air informercialsbest informercials bed airmattress sized air beds

bestair bed mattress antique doorknobsantique doorknob identification tipsdvd player troubleshootingtroubleshooting with the dvd playerflat panel television lcd vs plasmaflat panel lcd television versus plasma pic the bestadjustable bed air foam The best bed air foam

hoof prints antique equestrian printsantique hoof prints equestrian printsBuy air bedadjustablebuy the best adjustable air bedsair beds canadian storesCanadian stores for air beds

migraine causemigraine treatments floridaflorida headache clinicdrying dessicantair drying dessicantdessicant air dryerpediatric asthmaasthma specialistasthma children specialistcarpet cleaning dallas txcarpet cleaners dallascarpet cleaning dallas

vero beach vacationvero beach vacationsbeach vacation homes veroms beach vacationsms beach vacationms beach condosmaui beach vacationmaui beach vacationsmaui beach clubbeach vacationsyour beach vacationscheap beach vacations

bob hairstylebob haircutsbob layeredpob hairstylebobbedclassic bobCare for Curly HairTips for Curly Haircurly hair12r 22.5 best pricetires truck bustires 12r 22.5

washington new housenew house houstonnew house san antonionew house venturanew houston house houston house txstains removal dyestains removal clothesstains removalteeth whiteningteeth whiteningbright teeth

jennifer grey nosejennifer nose jobscalebrities nose jobsWomen with Big NosesWomen hairstylesBig Nose Women, hairstyles