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
0 answers

How to use Java Fest for applet automation?

I am a part time programmer trying to automate a java applet. I googled a lot and came to conclusion that Java fest is the best option. It is almost two hours I am trying to figure out how to use it but unable to do. I am unable to understand how to…
narayanpatra
  • 5,627
  • 13
  • 51
  • 60
2
votes
1 answer

Adding an item - different variable name

I have a form to add a text box to GridBagLayout. Is it possible that each addition of a text field, the field will have a different name for the variable? Because now every time adds the same name, but different x, y I was thinking to create a…
Aclber
  • 41
  • 1
  • 1
  • 6
2
votes
3 answers

Mobile Java Applet?

Is there any mobile platform that allows me to run Java Applets? In absence of browser integration, at least Java SE capabilities. I've heard of a mobile device capable of running Windows XP - that would probably include support for Java SE and…
luvieere
  • 37,065
  • 18
  • 127
  • 179
2
votes
1 answer

What is the best way of java and javascript interaction?

Excuse my lack of knowledge in many fundamental areas, but I am just learning how to create applets in java and how to allow interaction between the applet and the web page (javascript). At the moment I have an applet with an init() and method1().…
Nick
  • 117
  • 2
  • 10
2
votes
0 answers

Java Applet Freezes IE8 under Windows XP and JRE 1.6.0_35

i am having a Problem, When i am trieing to access an applet, which i deployed on the website, with the IE8 under XP, the IE freezes and crashes. This happens with the JRE Version 1.6.0_35 With the JRE version 1.6.0_24 the IE8 does Work without any…
SomeJavaGuy
  • 7,307
  • 2
  • 21
  • 33
2
votes
1 answer

How do I load one Java class from another?

SEE THIS link for the solution to the problem I am doing a project where I have a drop down list, which when an option is selected on the list, it loads an applet with custom settings. The name of the main class of the applet is…
awwerk1
  • 23
  • 4
2
votes
5 answers

System.getProperty("user.language") always return "en" not user current Language settings

This is now drying me mad. I have a javaApplet on top of a asp.net page. Within this javaApplet I must detect the user preferred language FireFox-Tools-Options-Content-Languages-Choose.I have 3 languages in there and the firstOne is…
Jo.
  • 187
  • 2
  • 5
  • 9
2
votes
1 answer

How to run applet in eclipse using web project

Hello I have tried the following code index.jsp java class PrintApplet.java import java.applet.Applet; import java.awt.Color; public class…
user2428568
  • 223
  • 1
  • 4
  • 18
2
votes
0 answers

Selenium WebDriver for Java Applet based websites

I have a website which uses a Java applet. I am trying to automate it using Cucumber & Selenium WebDriver. However, every time I run the website in browser, I get a java security alert (see image), which should be explicitly allowed to proceed…
Utsav Kesharwani
  • 1,715
  • 11
  • 25
2
votes
2 answers

Java Applet is not running in a browser

I am trying to run my applet in a browser, chrome/IE but I get the following message: Your security settings have blocked a local application from running Due to Oracle, changing security level in java control panel from high to medium will solve…
Mike Anderson
  • 77
  • 1
  • 2
  • 8
2
votes
2 answers

Creating a second applet(window) in processing

Hello guys i am trying to do a code where i can create a second applet in processing by passing on a sensible area. the code works fine except for 1 thing. when it passes over the sensible area it creates in a loop the same frame. here is the…
user2321978
  • 49
  • 1
  • 3
2
votes
1 answer

Allow either one name or another to be selected when a person uses the code

I am attempting force the user one of these names, name1, name2, or name3, whenever they uses the whole thing. It only seems to print out only the first name, Name1, as their name.…
Wacon
  • 23
  • 3
2
votes
0 answers

Applet - Both signed and unsigned code warning message only with 1.6.0_45

I'm working with legacy code where the login is performed through an applet (as I've commented it is legacy code ;D). We've been working with several JRE versions (1.6.0_29, 30 and 43) and all have been working without any problem. But the customer…
2
votes
1 answer

How do I use javax.swing components in an application?

Disclaimer: I am very new to Java, but I've been building .NET applications for 13 years. I'm trying to build this Java application that does some basic calculations for tutoring. It's honestly not that big of a program, but I can't even get it to…
Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
2
votes
1 answer

Zoom in and zoom out function in Jpanel

I have to add Zoom In and Zoom Out functionality to JPanel, which contains components like JLabel with ImageIcon. I want to Zoom JPanel with their components appropriately I tried with following code snippet but it did not work properly. The…
YuvRAJ
  • 94
  • 1
  • 3
  • 10