1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/* Get Applet's Document URL or Directory Base Example This java example shows how get the applet's HTML document URL or document base using getDocumentBase() method of Java Applet class. */ import java.applet.Applet; import java.awt.Graphics; import java.net.URL; /* <applet code="GetDocumentBaseExample" width=200 height=200> </applet> */ public class GetDocumentBaseExample extends Applet{ public void paint(Graphics g){ /* * To get Applet's HTML Document directory URL or the document base use * String getDocumentBase() * method of Java Applet class. */ URL appletDocDir = getDocumentBase(); g.drawString(appletDocDir.toString(), 50, 50); } } |
Example Output
Add Comment