AppletContext is the interface defined by java.applet. One application of java is to use active images and animation to provide a graphical means for different java based application.
It is used to get information from the applet’s execution environment.
The context of the currently executing applet is obtained by a call to the getAppletContext( ) method defined by Applet.
Methods
Applet getApplet(String appletName)
This method returns the applet specified by appletName if it is within the current applet context. Otherwise, null is returned.
Enumeration getApplets( )
This method returns an enumeration that contains all of the applets within the current applet context.
AudioClip getAudioClip(URL url)
This method returns an AudioClip object that encapsulates the audio clip found at the location specified by url.
Image getImage(URL url)
This method returns an Image object that encapsulates the image found at the location specified by url.
void showDocument(URL url)
This method brings the document at the URL specified by url into view. This method may not be supported by applet viewers.
void showDocument(URL url, String where)
This method brings the document at the URL specified by url into view. This method may not be supported by applet viewers. The placement of the document is specified by where as described in the text.
void showStatus(String str)
EXAMPLE - AppletContext: showDocument(URL url,String target)
import java.applet.AppletContext; import java.awt.Graphics; import java.net.URL; import javax.swing.JApplet; public class MainClass extends JApplet { public void paint(Graphics g) { AppletContext ac = getAppletContext(); try { URL url = new URL("http://www.java2s.com"); ac.showDocument(url, "frame2"); } catch (Exception e) { showStatus("Exception: " + e); } g.drawString("ShowDocument Applet", 10, 25); } }
No comments:
Post a Comment