This discussion is archived
12 Replies Latest reply: Oct 7, 2008 12:22 AM by 843810 RSS

how can i set the image icon in javahelp???

843810 Newbie
Currently Being Moderated
hi guys,

i wan to change the icon (java cup) at the left corner of the frame used by javahelp. How can i do this???

thanks
pradeep
  • 1. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    I'm trying to do the same.

    Did you get any private answer or solved the problem?

    Regards,
    Gabriel
  • 2. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    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
  • 3. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    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;

    try
    {
    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");
    return;
    }

    ((DefaultHelpBroker)hb).setActivationWindow(this);
    hb.setDisplayed(true);
  • 4. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    I tried it and it didn't work, neither on Windows nor Solaris.

    Gabriel
  • 5. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    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);
    ((DefaultHelpBroker)hb).setActivationWindow(thisHelp);
  • 6. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    Dear friend,

    It's great.

    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?

    Best regards,
    Harilal
  • 7. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    hi

    i tried in same way but the image is not changing..

    how to proceed..

    thanks
    nagesh
  • 8. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    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">
    <name>MainWin</name>
    <!-- Dimensiones iniciales -->
    <size width="640" height="480" />
    <!-- Posici&oacute;n inicial -->
    <location x="200" y="200" />
    <!-- T&iacute;tulo de la ventana -->
    <title>Sistema de Ayuda</title>
    <!-- Definimos la barra de herramientas de la ventana -->

    *<image>icon</image>*          

    </presentation>
  • 9. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    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)));
  • 10. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    Hello

    I tried your solution, but the helpwindow is always null. I have a reference to the helpBroker.
    Have you an idea?

    thank you
  • 11. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    Frame is created when help is about to be displayed. You must force frame creation by calling getLocation on WindowPresentation :
    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());
    Hackish, but it works.
  • 12. Re: how can i set the image icon in javahelp???
    843810 Newbie
    Currently Being Moderated
    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">
    ....
    <image>icon</image>
    </presentation>

    and that's that. It works fine and no code has to be bastardized within the *.java file that calls the helpBroker

    Cheers
    xtc