|
Applicet Framework for Applets and Applications v2.03 | ||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--be.arci.applet.JApplicet.Context
The execution environment for JApplicet applications (implementing the java.applet.AppletContext interface); also adds functionality, specific for JApplicet applications, that need not be distributed with JApplicet applets.
The methods in this class can be used by an JApplicet to obtain information about its environment.
Note:
If the JApplicet is loaded as an applet by a web
browser, the AppletContext will not be of this class type. The methods
in this class that we added in addition the AppletContext implementation
will not be available for JApplicet applets. These extra methods were
selected so that you should only want to call them in the 'as-application'
part of your code, typically the main method or it's callees;
in that part of it will be safe to blindly typecast
((JApplicet.Context)getAppletContext()).
If you do have to call them from other parts of your code
(like init() and start() and their callees), you will
have to test for isApplication() before casting, and may have
to publish the JApplicet$Context.class file together with
your applet on your website, because some browser JVM will try to
load JApplicet.Context for bytecode verification if they find a typecast
in an executed method. You can avoid this by dedoubling that part of code
as follows:
void methodA() {
if (isApplication())
((JApplicet.Context)getAppletContext()).doSomeThing();
void methodB() {
if (isApplication())
methodC();
}
void methodC() {
((JApplicet.Context)getAppletContext()).doSomeThing();
}
When the browser executes methodA, it might try to load the file
JApplicet$Context.class to verify the typecast, though
it will never be used because isApplication() will always be
false in a browser. methodB + methodC give you the same functionality,
but methodC will never be executed by the browser because of the
isApplication() test in methodB. So the bytecode for methodC
will not be verified and JApplicet$Context.class will not be loaded.
| Method Summary | |
java.applet.Applet |
getApplet(java.lang.String sName)
Finds and returns the applet with the given name in this execution context. |
java.util.Enumeration |
getApplets()
Finds all the applets in this execution context. |
java.applet.AudioClip |
getAudioClip(java.net.URL url)
Creates an audio clip. |
java.awt.Image |
getImage(java.net.URL url)
Returns an Image object that can then be painted on the screen. |
javax.swing.JTextField |
getStatusField()
Returns the status field of the JApplicet applition's AppletContext. |
java.io.InputStream |
getStream(java.lang.String key)
|
java.util.Iterator |
getStreamKeys()
|
void |
setActive(boolean swActive)
Activates or deactivates the JApplicet application. |
void |
setBrowser(Browser browser)
Sets the Browser for showing HTML and other documents from the JApplicet application. |
void |
setStatusField(javax.swing.JTextField tfStatus)
Sets the status field of the JApplicet applition's AppletContext; all subsequent showStatus() messages are directed to this field. |
void |
setStream(java.lang.String key,
java.io.InputStream stream)
|
void |
showDocument(java.net.URL urlDocument)
Equivalent to showDocument(url, "_top");. |
void |
showDocument(java.net.URL urlDocument,
java.lang.String sTarget)
Requests to show local document or the Web page indicated by the url argument. |
void |
showStatus(java.lang.String status)
You should not call this method: call JApplicet.showStatus() instead. This method is public only because it is defined in an interface (java.applet.AppletContext). |
void |
showUsage(java.lang.String sMessage,
boolean swExit)
Convenience method to pop up a 'typical use' dialog with parameter help, and exit. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public java.applet.AudioClip getAudioClip(java.net.URL url)
getAudioClip in interface java.applet.AppletContexturl - an absolute URL giving the location of the audio clip.JApplicet.getAudioClip(String sName)public java.awt.Image getImage(java.net.URL url)
This method always returns immediately, whether or not the image exists. When the applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.
getImage in interface java.applet.AppletContexturl - an absolute URL giving the location of the image.JApplicet.getImage(String sName)public java.applet.Applet getApplet(java.lang.String sName)
getApplet in interface java.applet.AppletContextsName - an applet name.JApplicet.runAsApplicationpublic java.util.Enumeration getApplets()
getApplets in interface java.applet.AppletContextpublic void showDocument(java.net.URL urlDocument)
showDocument in interface java.applet.AppletContextshowDocument(URL urlDocument, String sTarget)
public void showDocument(java.net.URL urlDocument,
java.lang.String sTarget)
| "_self" | Not applicable when running as application; acts the same as _top. |
| "_parent" | Not applicable when running as application; acts the same as _top. |
| "_top" | Show in the top-level frame of the current Browser window. |
| "_blank" | Show in a new, unnamed top-level window. |
| name | Show in the frame or window named name. If a target named name does not already exist, a new top-level window with the specified name is created, and the document is shown there. |
JApplicet.Context delegates the display of documents to an implementation of the Browser interface, that can be set by a call to setBrowser(Browser). The default Browser implementation is DummyBrowser, that does nothing at all. A Browser is free to ignore sTarget (just as it is free to ignore the complete showDocument() request).
showDocument in interface java.applet.AppletContexturlDocument - an absolute URL giving the location of the document.sTarget - a String indicating where to display
the page.Browser,
setBrowser,
JApplicet.getResource,
Viewing HTML documentspublic void showStatus(java.lang.String status)
Requests that the argument string be displayed in the status field. The status field for JApplicet application is normally placed in the JFrame containing the JApplicet panel, though subclasses can access the field and place it elsewhere.
showStatus in interface java.applet.AppletContextstatus - a string to display in the status window.getStatusField,
"java.applet.Applet.showStatus(status)"
public void setActive(boolean swActive)
throws java.lang.IllegalStateException
You only need to call this method if you initialized the JApplicet's application execution context with either or both swSetActive or swCreateFrame set to false in the call to runAsApplication.
java.lang.IllegalStateException - if the JApplicet's isActive() state
already equals the specified swActive paramater.JApplicet.runAsApplication,
"java.applet.Applet.isActive()"public javax.swing.JTextField getStatusField()
Use as follows:
((JApplicet.Context)getAppletContext).getStatusField();
Do not call this method if runAsApplication() has not been invoked.
showStatuspublic void setStatusField(javax.swing.JTextField tfStatus)
Normally when running as an application, this AppletContext will have added it's own status field to the parenting JFrame it created. If the user creates his own parenting Container, this AppletContext will not have created a status field, and the user can create one himself. It is the user's responsibility to add the status field Component to a container.
Use as follows:
((JApplicet.Context)getAppletContext).setStatusField(myTextField);
Do not call this method if runAsApplication() has not been invoked.
showStatuspublic void setBrowser(Browser browser)
Use as follows:
((JApplicet.Context)getAppletContext).setBrowser(new MyBrowser());
Do not call this method if runAsApplication() has not been invoked.
Browser,
showDocument
public void showUsage(java.lang.String sMessage,
boolean swExit)
The parameter help will contain the return value of getAppletInfo(), followed by sMessage, if not null, followed by the return value of getUsage(), if you override this method in your JApplicet. The default getUsage() implementation returns null, causing the display of the return values of getParameterInfo() and getReservedParameterInfo(), formatted according to the MessageFormat pattern definitions called "usage01" and "usage02" in Applicet_locale.properties.
Parameter help is shown in a modal JDialog .
sMessage - Extra message to show in the usage dialog.swExit - if true, this method calls System.exit(-1) to stop
execution immediately after disposal of the usage dialog.JApplicet.getUsage,
formatI18NString,
JApplicet.getI18NParameterInfo,
JApplicet.getReservedParameterInfo
public void setStream(java.lang.String key,
java.io.InputStream stream)
throws java.io.IOException
public java.io.InputStream getStream(java.lang.String key)
public java.util.Iterator getStreamKeys()
|
Applicet Framework for Applets and Applications v2.03 | ||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||