This discussion is archived
2 Replies Latest reply: Nov 12, 2009 2:51 AM by 843810 RSS

calling javahelp from javafx

843810 Newbie
Currently Being Moderated
I have JavaHelp accessed from a Java application. I am moving the application to JavaFX. I have tried rewriting the code I have but cannot make it work.

Does anyone have a working example?
  • 1. Re: calling javahelp from javafx
    843810 Newbie
    Currently Being Moderated
    AFAIK, JavaFX can include (or interact with) Swing, not viceversa, unless using some native and version dependent code.
    So I guess your HelpBroker, listeners and so on won't work if attached to JavaFX components.
    If this is what you mean by 'cannot make it work', I'm afraid there's not much you can do, unless rewriting a bunch of (javahelp) code.

    Bye.
  • 2. Re: calling javahelp from javafx
    843810 Newbie
    Currently Being Moderated
    The following code compiles but gives a runtime error on the HelpSet line. It doesn't like the null which appears to ask to system to find the default classloader.



    public class myHelp {

    static public HelpBroker startJavaHelp()
    {
    HelpBroker hb = null ;
         URL url = null;
    try
         {   url = new URL("file://help/help.hs");
    HelpSet hs = new HelpSet(null,url);
    hb = hs.createHelpBroker();
    System.out.println("created help broker");
         }
         catch(Exception e)
         {   e.printStackTrace();
    System.out.println("Url error here " + url);
         }
         return hb ;
    }

    }


    I can use ClassLoader instead but cannot determine what to load.


    static public HelpBroker startJavaHelp()
    {
    HelpBroker hb = null ;
         URL url = null;
    String helpHS = "help/help.hs";
    ClassLoader cl = ecowand.Main.class.getClassLoader();
    try
         {   url = HelpSet.findHelpSet(cl, helpHS);
    HelpSet hs = new HelpSet(null,url);
    hb = hs.createHelpBroker();
         }
         catch(Exception e)
         {   e.printStackTrace();
    System.out.println("Url error here " + url);
         }
         return hb;
    }

    The line

    ClassLoader cl = ecowand.Main.class.getClassLoader();

    flags an error in netbeans. It appears to only want .java file here, not .fx


    In my fx program, I call startJavaHelp() on startup, the idea being that this would give me the required HelpBroker that I could use, somehow, in the action when the Help button is pressed.

    bye