I am basically writing some code that makes a line graph, using Threads and seperate classes etc.. so originally the class that did the graphing was an applet. I am trying to run this as standalone and using another class to have main() SO far I think it has been ok where I use a Frame to hold the applet and run init() by creating an object instance of my applet class. Also the HTML file that ran this Applet.class had some parameters. I have managed to just hard code them into the JAVA class applet file but one of them I do not know what to do.
So my HTML snippet is: <applet code="example2A.class" width="400" height="300" codebase="."> <param name="title" value="A Strip Chart"> <param name="markers" value="marker.txt"> <param name="period" value="250"> </applet>
So for codebase="." I originally had in the applet code: try {
markersURL = new URL(getDocumentBase(),mfile); graph.setMarkers(new Markers(markersURL)); } catch(Exception e) { System.out.println("Failed to create Marker URL!"); }
mfile I just set to "market.txt" which is fine, but I do not know what to replace getDocumentBase() with as that expects a URL object. I did try:
markersURL = new URL((URL)".", mfile);
so that typecast attempt did not work. Any help is appreciated. Thanks
First of all getDocumentBase() "returns an absolute URL naming the directory of the document in which the applet is embedded. " Secondly, you cannot cast a String to an URL !!!! You must do new URL("./") maybe...