title: How to show a html file inside a JEditorPane
body: <p>I am trying to show a html file in a jeditorpane.</p>
  
  <p>The file is saved in the project folder and was generated by the program. It is a receipt called FredReceipt.html</p>
  
  <p>I understand how to use a jeditorpane for a url, however I have not been able to understand how I can load a file in through the tutorials etc... I have been reading from the web. I want to load the file in using a relative url. This is what I have at the moment, it's not working (obviously), it's catching the IOException.</p>
  
  <pre><code>public void showReceipt() {
      receiptPanel = new JPanel();
      receiptPanel.setVisible(true);
      receiptPanel.setBackground(new Color(250,251,253)); 
      String url = "FredReceipt.html";
      try {
        JEditorPane htmlPane = new JEditorPane("FredReceipt.html");
        htmlPane.setEditable(false);
        receiptPanel.add(new JScrollPane(htmlPane));
      } catch(IOException ioe) {
        System.err.println("Error displaying " + url);
      }
  
  }
  </code></pre>
  
  <p>I have also tried using the 'setPage()' method like this:</p>
  
  <pre><code>public void showReceipt() {
      receiptPanel = new JPanel();
      receiptPanel.setVisible(true);
      receiptPanel.setBackground(new Color(250,251,253)); 
      try {
        JEditorPane htmlPane = new JEditorPane();
        htmlPane.setPage(new URL("FredReceipt.html"));
        htmlPane.setEditable(false);
        receiptPanel.add(new JScrollPane(htmlPane));
      } catch(IOException ioe) {
        System.err.println("Error displaying file");
      }
  
  }
  </code></pre>
  
  <p>FredReceipt.html is obviously not a url, but I have read that files can be read in much the same as urls, I just haven't been able to find the correct way.</p>
  
  <p>I hope my question isn't too dumb, thanks a lot!</p>