This discussion is archived
1 Reply Latest reply: Dec 7, 2009 1:48 AM by 843810 RSS

Window-level context-sensitive help and JInternalFrames

843810 Newbie
Currently Being Moderated
Hi!

I am quite starter with JavaHelp.

I have a JFrame and several JInternalFrames. My application should provide window-level help by pressing F1 to show help about the current focused frame (Jframe or JInternalFrame).

In the JFrame I create the Helpset and HelpBroker with this method:
private void createHelp()
    {
        String helpHS = "help/javahelp/help.hs";
        // Find the HelpSet file and create the HelpSet object:
        ClassLoader cl = MainFrame.class.getClassLoader();
        try
        {
            URL hsURL = HelpSet.findHelpSet(cl, helpHS);
            helpSet = new HelpSet(null, hsURL);

        } catch (Exception ee)
        {
            // Say what the exception really is
            System.out.println("HelpSet " + ee.getMessage());
            System.out.println("HelpSet " + helpHS + " not found");
            return;
        }
        // Create a HelpBroker object:
        helpBroker = helpSet.createHelpBroker();
        jMenuItemHelp.setVisible(true);
        if(helpBroker!=null)
        {
            jMenuItemHelp.addActionListener(new CSH.DisplayHelpFromSource(helpBroker));
        }
    }
In the child JInternalFrames I try to set HelpId with this kind of code (for the Frame and RootPane also):
mainFrame.getHelpBroker().enableHelp(this, JavaHelpIndexes.HelpTopic1_index, mainFrame.getHelpSet());
mainFrame.getHelpBroker().enableHelp(this.getRootPane(), JavaHelpIndexes.HelpTopic1, mainFrame.getHelpSet());
CSH.setHelpIDString(this, JavaHelpIndexes.HelpTopic1);
CSH.setHelpIDString(this.getRootPane(), JavaHelpIndexes.HelpTopic1);
CSH.setHelpIDString(mHyperlinkUusiVaraus, JavaHelpIndexes.HelpTopic1_index);
java.awt.event.ActionListener bhelpal = new javax.help.CSH.DisplayHelpFromSource(mainFrame.getHelpBroker());
mHyperlink.addActionListener(bhelpal);
Javahelp-viewer launched, but no topic selected.

Help about help is appreciated...