Está en la página 1de 6

REALIZAR AYUDA CON JAVAHELP

Nils Murrugarra Llerena nineil.cs@gmail.com http://inf.unitru.edu.pe/~nineil/ Resumen: En este documento veremos la manera de realizar ayudas para programas hechos en Java mediante una librera: JavaHelp, veamos a continuacin los pasos que debemos realizar: 1. Descargar de la pgina de la sun: http://java.sun.com/products/javahelp/download_binary.html#download el archivo: javahelp-2_0_05.zip 2. Descomprimir y copiar la carpeta jh2.0 a D: 3. Crear el proyecto jhelp en NetBeans 4. Crear un formulario con una pestaa ayuda, donde el nombre del men sea menuAyuda con item: itemAyuda donde el contenido sea ver Ayuda.

5. En el constructor de la clase agregar el siguiente cdigo:


HelpSet hs; HelpBroker hb; String helpHS = "Master.hs";//Archivo q indicara la estructura de la ayuda ClassLoader cl = getMyLoader(); try { URL hsURL = HelpSet.findHelpSet(cl, helpHS); hs = new HelpSet(null, hsURL); } catch (Exception ee) { //Error

System.out.println( "HelpSet " + ee.getMessage()); System.out.println("HelpSet "+ helpHS +" not found"); return; } hb = hs.createHelpBroker();//Crea interfaz de ayuda this. itemAyuda.addActionListener(new CSH.DisplayHelpFromSource(hb));//Aade ayuda

6. Crear un mtodo getMyLoader:


private ClassLoader getMyLoader() { ClassLoader back; back = this.getClass().getClassLoader(); return back; }

7. Compilemos Al compilar nos saldrn algunos errores. 8. Agreguemos las siguientes libreras import javax.help.*; import java.net.*; 9. Aadir las siguientes rutas al path del sistema: a. D:\jh2.0\javahelp\bin 10. Aadiendo Librera Aadamos las libreras src.jar(de D:\jh2.0), jhindexer.jar(de D:\jh2.0\javahelp\bin) y jhsearch.jar(de D:\jh2.0\javahelp\bin) al proyecto. Vamos al panel de la izquierda en el tem libraries, add Jar Flder y aadimos las libreras. 11. Ahora al realizar la compilacin todo sale ok. 12. Copiar todo lo que contiene la carpeta Archivos .. \jHelp\build\classes dependiendo de la ruta creada en el proyecto. 13. Compilar y Ejecutar, y al pulsar en VerAyuda debemos ver:

14. Analicemos la ayuda, veamos los archivos dentro de la carpeta Archivos a. Icono Ayuda: Muestra la ayuda, veamos el contenido de MasterTOC.xml:
<!DOCTYPE toc PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN" "http://java.sun.com/products/javahelp/toc_1_0.dtd"> <toc version="1.0"> <tocitem text="Ayuda Compilador Grfico"> <tocitem text="Inicio" target="index"/> <tocitem text="Requisitos y Advertencias" target="node1"/> <tocitem text="Acerca del Software" target="node2"/> <tocitem text="Utilizando el Software"> <tocitem text="Inicio" target="node3"/> <tocitem text="Comandos" target="node4"/> <tocitem text="Ejecucin" target="node5"/> </tocitem> <tocitem text="Escribanos" target="node6"/> </tocitem> </toc>

Como se puede apreciar, escojamos una instruccin para nuestro ejemplo: <tocitem text="Escribanos" target="node6"/> , Escribanos viene a ser un nombre q sea aadir al men y node6 la pgina web a donde har referencia.

b. Icono ndice: Adems de mostrar la ayuda, permite realizar bsqueda en tales, veamos el contenido de MasterIndex.xml:
<!DOCTYPE index PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN"

"http://java.sun.com/products/javahelp/index_1_0.dtd"> <index version="1.0"> <indexitem text="Inicio" target="index"/> <indexitem text="Requisitos y Advertencias" target="node1"/> <indexitem text="Acerca del Software" target="node2"/> <indexitem text="Utilizando el Software" target="node3"/> <indexitem text="Comandos" target="node4"/> <indexitem text="Ejecucin" target="node5"/> <indexitem text="Escribanos" target="node6"/> </index>

Como se puede apreciar, escojamos una instruccin para nuestro ejemplo: <indexitem text="Escribanos" target="node6"/> , Escribanos viene a ser un nombre q sea aadir al men y node6 la pgina web a donde har referencia.

c. Icono Bsqueda: Permite realizar bsqueda de texto en el contenido de cada archivo.

15. Veamos ms Archivos a. Master.jhm: Relaciona un nombre dado con una determinada pgina web. Veamos su contenido:
<?xml version='1.0' encoding='ISO-8859-1' ?> <!DOCTYPE map PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN" "http://java.sun.com/products/javahelp/map_1_0.dtd"> <map version="1.0"> <mapID target="index" url="master/index.html" /> <mapID target="node1" url="master/node1.html" /> <mapID target="node2" url="master/node2.html" /> <mapID target="node3" url="master/node3.html" /> <mapID target="node4" url="master/node4.html" /> <mapID target="node5" url="master/node5.html" /> <mapID target="node6" url="master/node6.html" /> </map>

b. Master.hs: Define la estructura de toda la interfaz de ayuda. Veamos su contenido:


<!-- views --> <view> <name>TOC</name> <label>Ayuda</label> <type>javax.help.TOCView</type> <data>MasterTOC.xml</data> </view> <view>

<name>Index</name> <label>ndice</label> <type>javax.help.IndexView</type> <data>MasterIndex.xml</data> </view> <view> <name>Search</name> <label>Bsqueda</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favoritos</label> <type>javax.help.FavoritesView</type> <data>MasterIndex.xml</data> </view> </helpset>

c. Creemos la carpeta JavaHelpSearch para la icono bsqueda, para realizar una bsqueda por contenido de texto debemos de utilizar la funcin hindexer: i. Inicio, ejecutar, cmd ii. cd .\jHelp\build\classes , dependiendo de la ruta donde se este iii. hindexer master iv. En la carpeta .\jHelp\build\classes, se ha creado una carpeta JavaHelpSearch, la que nos ayudara para realizar la bsqueda por contenido.

También podría gustarte