Applets Section Index | Page 5
Are applets covered on the Java certification exams?
About the only thing you'll need to know about applets is the default layout manager. It won't hurt to know the APPLET tag, the life cycle methods, and parameter handling.
There is no mention of a...more
My applet runs fine with appletviewer but not in the browser, what can be the problem?
Applets loaded through appletviewer are more then likely loading their classes from the local CLASSPATH, not over the network. As such, they get different permissions and can do things that applet...more
What purpose does the getAppletInfo() method serve?
Absolutely none.
Technically speaking, you can override the method to return the applet's author, version, and copyright. But, there is no way to get the information from the browser.
What purpose does the getParameterInfo() method serve?
Like getAppletInfo(), this method is rarely used. When implemented,
you should return the names, types, and description of the parameters your applet accepts. They are all strings, so there is no...more
What's this rumor I hear about not needing to convert HTML when I use the Java Plugin?
Sun's latest Java Plug-in version directly replaces the VM in Windows browsers, forgoing the need to run the HTML converter.
Why can't I load an applet class from the parent directory?
If you are using something like "CODE=../ClassName.class", you have to realize that the CODE attribute of the APPLET tag is not meant to specify directory names, only class names. To load the appl...more
Can Images respond to mouse events?
Can Images respond to mouse events?
Instead of a button, i need to use Images and want to load different images when different mouse events are fired. what i am currently doing now is drawing an im...more
How can I show an Acrobat (PDF) file within an applet?
The easiest way is to just call showDocument() and pass the method the URL of the PDF file.
How do I specify a JAR file when using the OBJECT tag with the Java Plug-in?
All you have to do is specify the archive with a PARM named ARCHIVE. Something like the following:
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 790 HEIGHT = 478 NAME =...more
How do I load an image onto a JButton in an applet? new JButtion("foo.gif") throws a security exception.
Passing a String to a JButton tries to load the image from a File. You need to create an ImageIcon with URL and pass that into the constructor:
URL picURL = getClass().getResource("mypic.gif");
...more
How can I easily provide default values for when applet parameters are not specified?
Here's a helper method that you can use to do that:
import java.applet.*;
public class AppletUtils {
private AppletUtils() {}
public static String getParameter(
Applet applet, String...more
How can I prevent the "Applet started" message from appearing in the status line?
You can't really prevent this. The best you can do it hide it by repeatedly showing a status message in a thread:
getAppletContext().showStatus("");
This does hinder the use of status messages fo...more
I get a load: class XXX not found message when I try to load my applet, what's wrong?
Be sure to check the case and location of the .class file on the Web server. Either the CODE attribute specify the wrong class name, the class name is saved with the wrong case, or the class file ...more
What is the default layout manager of an applet?
For a java.applet.Applet, the default layout manager is FlowLayout.
For the content pane of a javax.swing.JApplet, the default layout manager is a BorderLayout.
Why do I get a security exception when I use ".." in the path to try to get an image file?
The SecurityManager considers going up a level from the code / document base to be providing access to something that you shouldn't have access to. Thus:
getImage(getDocumentBase(), "../foo.jpg")...more