Questions tagged [applet]

Applet means 'small application'. This has become commonly used to describe Java applets embedded in web pages. And in that context, applets can be regarded as outdated technology.

Applet

Applet means 'small application'. This term has become commonly used to describe Java applets embedded in web pages - to the extent that the HTML based applet element is for embedding Java applets.

That being said:

  • An applet does not need to be embedded in a web page
  • An applet does not need to be written in Java
  • Many embedded Java applets are not 'small'

Gradually this term is being dragged back to its original meaning. In the more general sense, it might be applied to (for example) operating system settings or configuration applets. Such OS specific applets would typically not be written using Java.

Having covered the general meaning, and recognizing that the common usage of 'applet' is still 'Java applet', the rest of this entry will focus on Java applets.


Java Applet

Looking from the specific Java applet context, it is important to understand that no modern browser is supporting Java plugins any more; and therefore Java applets are not supported any more, too! This means: Java applets can be seen as a product that has reached "end of life"; it should not be used any more when developing new products; applets are only relevant in the sense of "how to migrate away" from them.

Java applets are applications written using the Java programming language that are embedded in web pages. Applets typically provide dynamic functionality that is not supported by plain HTML or a combination of HTML and JavaScript.

Perhaps ironically, the functionality of JavaScript is sometimes invoked from Java applets to achieve things that applets cannot do on their own. Further, the deployJava.js JavaScript provided by Oracle is designed to launch applets after checking a suitable minimum Java version is installed. While Java can do things that JavaScript cannot - most modern applets would not get very far if JavaScript was disabled in the user's browser!

Many 'beginner books' on Java seem to rush into applet development in early stages in the book. This is a huge mistake. Any text that does so should be considered suspect.

While applets might seem easy to develop, they are actually quite tricky. To deploy an applet reliably to 'all comers' (or at least the vast majority) on the WWW is an order of magnitude more difficult again. For more details See Why CS teachers should stop teaching Java applets, a blog entry by the top ranked provider of answers for the applet tag.

The Java applet API provides methods considered handy to web based applications. These include methods to gain images and audio clips, discover and communicate with other applets, ascertain the code base and document base (where am I?) to allow relative references to resources (images, clips, text files, etc.) that the applet might use.

Applets could be embedded in web pages since Java 1.1. With Java 1.2 came Java Web Start, which could launch both applications and applets as free floating entities (not embedded in a web page). With the release of Java 1.6.0_10, applets could remain embedded in web pages, but they also access the functionality of JWS and services of the JNLP API.

Applet 'Hello World' Example

This example requires the Java Development Kit installed. Visit Java SE Downloads for the latest JDK.

/* <!-- Defines the applet element used by the appletviewer. -->
<applet code='HelloWorld' width='200' height='100'></applet> */
import javax.swing.*;

/** An 'Hello World' Swing based applet.

To compile and launch:
prompt> javac HelloWorld.java
prompt> appletviewer HelloWorld.java  */
public class HelloWorld extends JApplet {

    public void init() {
        // Swing operations need to be performed on the EDT.
        // The Runnable/invokeAndWait(..) ensures that happens.
        Runnable r = new Runnable() {
            public void run() {
                // the crux of this simple applet
                getContentPane().add( new JLabel("Hello World!") );
            }
        };
        SwingUtilities.invokeAndWait(r);
    }
}

See also

7462 questions
2
votes
1 answer

Dragging a file from a JList to a Windows Explorer window

First I just want to admit that I'm not the sharpest Java developer out there. My strengths/experiences are mostly in JavaScript, etc. browsers. I've been asked to create an applet that can be used for dragging/dropping files into the browser…
tjb1982
  • 2,257
  • 2
  • 26
  • 39
2
votes
2 answers

No security level slide bar in Java control panel

I am unable to configure Java security settings using the Java Control Panel. With the latest Java update I can no longer run simple applets. Instructions say to reset security settings. All instructions refer to a slide bar in the Security tab. All…
user2336268
  • 21
  • 1
  • 2
2
votes
0 answers

frozen security warning dialog

I have applet which deploy through html on client side. After update jdk with jre to latest version - 1.6.0_45 i got problem with frozen security warning dialog. When applet is loaded then dialog appears and all buttons (Yes, No, More information)…
Mrusful
  • 1,503
  • 1
  • 18
  • 32
2
votes
4 answers

Executing a command from the web browser

What is the best way to execute a command on the client computer via the web browser? I know a Java applet is one way, but I really don't want to use Java. Will a firefox plugin work?
sanbornm
  • 187
  • 1
  • 7
2
votes
0 answers

ClassCastException running Applet after update to JRE 7u21

I'm working on a signed Applet that will no longer start under version 7u21 of the JRE. I've recompiled the applet using the 7u21 JDK, I've added the Trusted-Library:true line to the manifest (and removed it again after it caused a…
QueyJoh
  • 146
  • 1
  • 9
2
votes
1 answer

How to set automatic focus to Java applet on js

I made an applet. It's starting when web page is loaded. But applet lost focus, when web page lost focus too and need to click on area of applet and then it gained focus. I'm tried variants but it's not…
Alexandr
  • 127
  • 1
  • 1
  • 13
2
votes
1 answer

Extract source file of an Applet from a website

I want to see the source files of this Applet How can I do to get it?
mpluse
  • 1,857
  • 6
  • 18
  • 25
2
votes
1 answer

Applet Java 7 update 21: Cannot set AWTKeyListener on default Toolkit

In my self-signed applet (that may possibly become a CA-signed applet in near future) in which I have a fairly complex Swing GUI, I need to detect whenever the user has the SHIFT- or CONTROL-key pressed. I am using this in combination with…
2
votes
1 answer

Applet does not cache jar files

I'm having issues identifying why a few heavy .jar files are not being cached at the client side. The applet runs fine, but it lazy-downloads the heavy jar libs on every run (specifically aws-java-sdk and xuggler) The applet: Is applied to the HTML…
Jonas Bylov
  • 1,494
  • 2
  • 15
  • 28
2
votes
2 answers

Java applet to upload a file

I am looking for a Java applet to read a file from client machine and creat a POST request for PHP server uploading. PHP script on server should receive the file as normal file upload in FORM submit. I am using the following code. The file…
user189352
  • 855
  • 4
  • 18
  • 26
2
votes
1 answer

getImage method is showing a blank

I have tried numerous solutions, and I can't seem to find the issue with my code. I have checked the path names, the permissions for the files, and tried several different file names for the image. The image isn't showing up. private Character…
user1610810
  • 99
  • 1
  • 5
2
votes
1 answer

How to detect if browser will block java applet due to a need for update

In general, browsers (I see this esp. with Safari) are kind enough to inhibit a Java applet from running if it senses that a security related update for Java exists. It seems to do this quietly... my applet just "sits-and-spins" in the browser…
Pete E.
  • 163
  • 2
  • 7
2
votes
3 answers

reset the text area contents

I have this code.. here when i input number "6" in the textfield, text should be displayed in the textarea..but after that if i input any other number i want the textarea contents to be clear. But when I execute my code, the old contents of the…
praveena
  • 41
  • 1
  • 1
  • 9
2
votes
1 answer

Adding picture in jlist

I am writing a simple text based chat application using applets in java, which consists of few components & one of them is my Jlist which provides list of online users at that particular point of time. What i want is that i need to set a small…
puneetverma0711
  • 145
  • 3
  • 3
  • 10
2
votes
1 answer

Java applet sortable list

I'm looking for Java code, suitable for java-applet that is close to the functionality of JQuery Sortable: http://jqueryui.com/sortable/ Does anybody knows something suitable? (preferable free, but not strictly necessary...) Alternatively, do you…
user1028741
  • 2,745
  • 6
  • 34
  • 68
1 2 3
99
100