This content has been marked as final. Show 12 replies
I'm trying to do the same.
Did you get any private answer or solved the problem?
I'm trying to do the same - have you found out how to set it?
I'd be forever indebted to you if you could tell me how.
Thanks ever so much in advance
If your main application extends a JFrame and you have an icon image set for this frame using the 'setIconImage' then it's straight forward. Instantiate your help to display within your current frame object using 'this'. The following code is an example only and is not final, but you'll get the idea...
HelpSet hs = null;
HelpBroker hb = null;
URL hsURL = HelpSet.findHelpSet(null, "url to my help");
hs = new HelpSet(null, hsURL);
hb = hs.createHelpBroker();
catch (Exception ee)
System.out.println("HelpSet "+hs+" can not be found");
I tried it and it didn't work, neither on Windows nor Solaris.
A friend of mine had similar trouble even though it worked for me. I couldn't figure it out. He tried the following. He created a JDialog class first to render the help...
HelpDialog thisHelp = new HelpDialog(this);
It worked for me, the icon changes, but the Help window disappears, when the screen for which the help is set, is closed.
This should not happen, the Help window should remain there,got any solution for this?
i tried in same way but the image is not changing..
how to proceed..
Bueno, lo que yo hice para setear el icono en el javahelp fue lo siguiente:
en el archivo .jhm --
<!-- Images -->
<mapID target="icon" url="Images/tgsdc23png.png" />
y en el archivo .hs en el tag de presentation
<presentation default="true" displayviews="true" displayviewimages="true">
<!-- Dimensiones iniciales -->
<size width="640" height="480" />
<!-- Posición inicial -->
<location x="200" y="200" />
<!-- Título de la ventana -->
<title>Sistema de Ayuda</title>
<!-- Definimos la barra de herramientas de la ventana -->
Try this (I assume you already have reference to the HelpBroker object):
WindowPresentation wp = ((DefaultHelpBroker)hb).getWindowPresentation(); helpwindow = (JFrame)wp.getHelpWindow(); helpwindow.setIconImage(Toolkit.getDefaultToolkit().createImage(this.getClass().getClassLoader().getResource(path to image file)));
I tried your solution, but the helpwindow is always null. I have a reference to the helpBroker.
Have you an idea?
Frame is created when help is about to be displayed. You must force frame creation by calling getLocation on WindowPresentation :
Hackish, but it works.
HelpBroker hb = StaticUtils.helpSet.createHelpBroker(); WindowPresentation wp = ((DefaultHelpBroker)hb).getWindowPresentation(); // force frame creation wp.getLocation(); JFrame jfrmHelp = (JFrame)wp.getHelpWindow(); jfrmHelp.setIconImage(new ImageIcon(classLoader.getResource("help.gif")).getImage());
Chechar you are positivelly correct. Your solution is the most effective and eloquent as far as including your own custom icon on the JavaHelp main frame.
Just to repeat his response;
add the icon you wish to display in the map file like this ->
<mapID target="icon" url="images/MyIcon.gif" /> // || png || bmp etc
then in the .hs file in the presentation layer
<presentation default=true displayviews="true" displayviewimages="true">
and that's that. It works fine and no code has to be bastardized within the *.java file that calls the helpBroker