Pre-Requisites
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
- Choose File > New Project. Under Categories, select NetBeans Plug-in Modules.
NetBeans plug-in module support provides three project types: - Module Project. Creates a template for a standalone plug-in module.
- Library Wrapper Module Project. Creates a plug-in module for an external JAR file required by one or more plug-in modules.
- Module Suite Project. Creates a template for a set of interdependent plug-in modules and library wrapper modules, which you want to deploy together.
- Select Module Project. Click Next.
- 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.
- 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)
- Right click the project Stokenizer folder and select New->File/Folder
- In the New File wizard, choose NetBeans Module Development under Categories and Window Component under File Types. Click Next.
- 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.
- In the Name, Icon, Location Panel, fill up the name as "Tokenizer" and click Finish.
- Your Project window will have some files generated like TokenizerAction.java , TokenizerTopComponent.java and some xml files. (Figure 2)
- 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.
- Right click on the jButton1 and choose Events, then Action, then ActionPerformed() so that the event listener is registered with the jButton1.
- 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)
- Enter "Hello + Samir,;Minakshi,(krishna)*,Rama$,hari" as the Input String
- Enter the delimiters string as "+;()*$"
- Press the Button "Parse".
- The output will be Hello
Samir,
Minakshi,
krishna
,Rama
,hari - 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:
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."
Please, please use meaningful variable names, eg "delimiters" instead of "str2", "names" instead of "str1", "nameField" instead of "jTextField1", etc.
Hi,
Your Tutorial works under netbeans ide 6.5
Masoud
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
Post a Comment