In any program or application, most of the times when pressing the F1 key, a help system is opened referring to that utility.
I am in my project and I have created a help system, which should be opened by pressing F1 but not ... 1) Fail to press F1, it does not do anything.
2) I have a menu with a button and open the help system by clicking twice.
Code:
private void lanzarAyuda(){
try{
//Carga el fichero de ayuda.
File fichero = new File("sistema_ayuda" + File.separator + "helpset.hs");
URL hsURL = fichero.toURI().toURL();
//Crea el HelpSet.
HelpSet helpset = new HelpSet(getClass().getClassLoader(), hsURL);
HelpBroker hb = helpset.createHelpBroker();
//Mostrar el sistema de ayuda al pulsar F1.
hb.enableHelpOnButton(button_ayuda, "principal", helpset);
hb.enableHelpKey(getRootPane(), "principal", helpset);
//Colocamos la posicion de la ventana (Posicion p).
hb.setSize(new Dimension(800,600));
//Colocamos el tamaño de la ventana (Dimension d).
hb.setLocation(new Point(250,90));
}catch(Exception e){
e.printStackTrace();
}
}
private void button_ayudaActionPerformed(java.awt.event.ActionEvent evt) {
lanzarAyuda();
}