Search code examples
javaswingnetbeansembedded-resourcemenubar

How to add myAppHelp.pdf file in netbeans platform application's menubar?


I made Desktop App in netbeans platform in Java Swing. Now, how can i put myapp's helpOfApp.pdf file in netbeans platform app(MyApp)'s menu bar?


Solution

  • how to add this .html file to menubar in my app?

    • Add a menu item to a menu that is added to the bar.
    • Add an Action (or ActionListener) to the menu item.
    • Add an accelerator of F-1 (help).
    • On action.
      • Get an URL instance using something like
        URL urlToResource = this.getClass().getResource("/path/to/the.resource");
      • Open a JEditorPane (non-editable, and possibly with a link listener) pointing to urlToResource.

    See the relevant 'keyword+java+tutorial' for more details on each step.


    Tip: ensure all resources (e.g. linked HTML, CSS, images etc.) are:

    • accessed by relative path
    • on the run-time class-path of the app.