package org.best.example;
/*
Get Applet Directory URL or Code Base Example
This java example shows how get the current applet's directory URL or
code base using getCodeBase() method of Java Applet class.
*/
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
/*
<applet code="GetCodeBaseExample" width=200 height=200>
</applet>
*/
public class GetCodeBaseExample extends Applet{
public void paint(Graphics g){
/*
* To get Applet directory URL or the code base use
* String getCodeBase()
* method of Java Applet class.
*/
URL appletDir = getCodeBase();
g.drawString(appletDir.toString(), 50, 50);
}
}
/*
Get Applet Directory URL or Code Base Example
This java example shows how get the current applet's directory URL or
code base using getCodeBase() method of Java Applet class.
*/
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
/*
<applet code="GetCodeBaseExample" width=200 height=200>
</applet>
*/
public class GetCodeBaseExample extends Applet{
public void paint(Graphics g){
/*
* To get Applet directory URL or the code base use
* String getCodeBase()
* method of Java Applet class.
*/
URL appletDir = getCodeBase();
g.drawString(appletDir.toString(), 50, 50);
}
}
No comments:
Post a Comment