How to get Applet’s document URL?

DeeKay August 27, 2011 at 1:37 am · java.applet

Below java code show how to get Applet’s document URL –

/**********************************************************************************
 * Created on Nov, 2004 Copyright(c) http://kodehelp.com All Rights Reserved.
 **********************************************************************************/
package com.kodehelp.java.applet;

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;

/**
 * @author http://kodehelp.com
 *
 */
public class AppletGetDocumentBase extends Applet {

	Image image;

	@Override
	public void init() {
		System.out.println(getDocumentBase());
		image = getImage(getDocumentBase(),"logo.png");
	}

	@Override
	public void paint(Graphics g) {
		g.drawImage(image, 0, 0, this);
	}

}