Original article: http://platform.netbeans.org/tutorials/nbm-google.html
Source code: http://www.netbeans.org/files/documents/4/570/GoogleToolbar.zip
The operation is basically the same as that in the previous article.
1. See the previous article to create a project. Here, I will only put it on the toolbar.
2. on the "Gui registration" Panel, select "Global toolbar button ". Set the value.
3. On the "name, icon, and location" Panel, type "Class Name" in Google Action, And then type the Google Toolbar in "display name. In the "icon", find a 16x16 pixel Google icon in the file system.
4. create a googlepanel-like gui. Use the GUI designer to drag a jlabel and jtextfield to the Panel to change the size and layout and implement the keytyped event of jtextfield. The event processing is as follows: private void txtgooglekeytyped (Java. AWT. event. keyevent EVT )... {
// Todo add your handling code here:
Int I = EVT. getkeychar ();
If (I = 10)... {// The enter key
// We display the Google URL.
Try ...{
Urldisplayer. getdefault (). showurl
(New URL ("http://www.google.com/search? Hl = en & Q = "+ txtgoogle. gettext () +" & btng = Google + search "); // noi18n
} Catch (exception EEE )...{
Return; // nothing much to do
}
}
}
Press the Enter key and use the default browser to open the Google website to query the content you entered. The urldisplayer class is used. Add the jar package and import the corresponding classes. Please refer to the previous article.
5. Open googleaction. Java, implementation method gettoolbarpresenter returns the realistic component after the toolbar is set out: Public java. AWT. Component gettoolbarpresenter ()...{
Return retvalue;
}
Is googleaction. Java adds the attribute retvalue, googlepanel retvalue = new googlepanel ();
6. view the results. In the "project" window, right-click the project and select "Install/reload on the Target Platform ".