Thursday, 15 October 2015

Filled Under:

Tutorial On GetDocument Base And GetCodeBase Using Applet

Often we need to create applets that will need to explicitly load media and text.java that allow the applet to load data from directory holding html file that sart the applet and directory from which applet file was loaded.these directories are returned as URL objects .

JAVA CODING:

import java.applet.*;
import java.awt.*;
import java.net.*;
public class bases extends Applet
{

public void paint(Graphics g)
{
String msg;
URL url = getCodeBase();
msg = "Code base:"+url.toString();
g.drawString(msg,10,40);
}

}

HTML CODING:

<html>  
<body>  
<applet code="bases" width="300" height="300">  
</applet>  
</body>  
</html>



0 comments:

Post a Comment