Hey all!
How would I go about creating a URL that references to html files on my hard-drive? I've tried to create a new URL object and sending the constructor strings like "file://C:/test.html", "file://C:\test.html", and "c:\test.html" but none of them seem to work.
Heres the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| package CarringtonPlace.Help; import CarringtonPlace.IView.IBEIView; import CarringtonPlace.Model.HelpBook; import CarringtonPlace.Model.Constants;
import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.UIManager;
import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeSelectionModel; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener;
import java.io.File;
import java.net.URL; import java.io.IOException; import java.awt.Dimension; import java.awt.GridLayout;
public class HelpHTMLPane extends JEditorPane implements IBEIView { private HelpBook model;
private URL helpURL;
public HelpHTMLPane(HelpBook theModel) { super(); this.model = theModel; this.initializeHelp(); this.model.addView(this); } private void initializeHelp() { String s = "file://C:/test.html"; try { this.helpURL = new URL(s); } catch (Exception e) { System.err.println("Could not parse URL address."); } if (helpURL == null) { System.err.println("Couldn't open help file: " + s); } else { System.out.println("Help URL is " + this.helpURL); } this.displayURL(helpURL); } private void displayURL(URL url) { try { if (url != null) { this.setPage(url); } else { this.setText("File Not Found"); System.out.println("Attempted to display a null URL."); } } catch (IOException e) { System.err.println("Attempted to read a bad URL: " + url); } }
public void updateView() { } public void updateColors() { }
} |
I'd appreciate any input on this!
Thx,
Jarrett
aka. Chisser98