4 Replies Latest reply: Sep 12, 2008 10:25 AM by 843810 RSS

    JavaHelp : context-sensitive help not working for JMenuItem

    843810
      Hi,

      I want to provide context-sensitive help for my menu items. For that I used the following method

      closeMenu = new JMenuItem("Close");
      helpBroker.enableHelpKey (closeMenu, "CLOSE", helpSet);

      I used the same method for JButton it works.
      I am using jre1.4.2_02.

      Thanks,
      Usha
        • 1. Re: JavaHelp : context-sensitive help not working for JMenuItem
          843810
          Usha,

          Have you tried calling the enableHelpOnButton() method on your help broker object.
           public void enableHelpOnButton(MenuItem, String helpID, HelpSet hs, String presentationWindowType, String presentationName)
          • 2. Re: JavaHelp : context-sensitive help not working for JMenuItem
            843810
            Hi,

            I have tried using enableHelpOnButton(MenuItem, String helpID, HelpSet hs) method. With this on clicking the menu the help opens, but I want the action to happen on pressing F1 on the menu item.

            The method you specified is not avialable with the Java Help APIs that I am using.

            I have tried the following too, even this does not give desired results.
            helpBroker.enableHelp ( NEWMenuItem , "NEW" , helpSet ) ;

            Please let me know if you get any solution.

            Thanks,
            Usha
            • 3. Re: JavaHelp : context-sensitive help not working for JMenuItem
              843810
              Have you tried to add a listener to the MenuItem that reacts on the F1 button? Probably not really what you want but that should work.
              • 4. Re: JavaHelp : context-sensitive help not working for JMenuItem
                843810
                It's a bug - I decided to respond since I've just had to solve the same problem and this was the thread that kept popping when I was searching for the solution ...

                enableHelp(Component, String, HelpSet) should add an action listener to the component but it doesn't. Under the bonnet all it does is set the HelpID and HelpSet as client properties on the component.

                To get round this you have to add the listener manually ...

                hb.enableHelp(helpItem, "helpkey", helpSet)
                helpItem.addActionListener(new CSH.DisplayHelpFromSource(hb));          

                and it will work in the same way as F1 and Buttons (which is where I worked this out).