The Artima Developer Community
Sponsored Link

Java Answers Forum
codebase to URL

1 reply on 1 page. Most recent reply: Jul 5, 2003 3:42 AM by zenykx

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
kulsoom

Posts: 1
Nickname: kuls
Registered: Jul, 2003

codebase to URL Posted: Jul 1, 2003 4:36 PM
Reply to this message Reply
Advertisement
Hi,

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


zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: codebase to URL Posted: Jul 5, 2003 3:42 AM
Reply to this message Reply
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...

Flat View: This topic has 1 reply on 1 page
Topic: string to long Previous Topic   Next Topic Topic: How instanciate a class in the JVM ??

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use