getDocumentBase()是什么意思?

来源:百度知道 编辑:UC知道 时间:2024/06/17 22:29:00
这是一个电子相册的程序,如题,我觉得那个是不是应该表示相片的位置呢?可是具体又是哪里?谢谢各位大虾.

源程序如下:
import java.applet.*;
import java.awt.*;
public class ElectroAlbum extends Applet
{
private Choice myChoice;
private String[] myString1,myString2;
private int totalPics;
private Image offI;
private Image[] img;
private Graphics offG;
private MediaTracker imagetracker;
public void init()
{
this.setLayout(null);
myChoice=new Choice();
myChoice.setBounds(10,10,290,20);
totalPics=Integer.parseInt(getParameter("TotalPic"));
System.out.println(totalPics);
myString1=new String[totalPics];
myString2=new String[totalPics];
img=new Image[totalPics];
for(int i=0;i<totalPics;i++)
{
myString1[i]=new String("");
myString2[i]=new String("");
}
String

getDocumentBase()
获取文件的基本路径

例如:
getImage(getDocumentBase(),"Ex7_3.jpg");以基本路径+Ex7_3.jpg文件为基础,取得图像类iImg=getImage(getDocumentBase(),"Ex7_3.jpg");把取得的图像类赋给变量iImg

你的数据源应该是文挡吧?我的理解是从你的数据源中取得getImage()方法需要的参数.然后返回值赋给img[i]

Applet类中getDocumentBase()和getCodeBase()的区别
Applet类中提供了这2种方法帮我门获取URL对象,其中getDocumentBase()方法返回URL对象,代表了包含Applet的HTML文件所在目录,而getCodeBase()方法返回的URL对象代表了applet文件即.class文件所在目录。它根据HTML文件的"Applet"标记中的CODEBASE属性值计算出来,若该属性没有设置则返回该HTML文件所在目录

Applet.getDocumentBase();

public URL getDocumentBase()
Gets the URL of the document in which this applet is embedded. For example, suppose an applet is contained within the document:
http://java.sun.com/products/jdk/1.2/index.html
The document base is: