Applet Code

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.
go to previous page   go to home page   go to next page

Answer:

An ActionEvent, same as for an application.

Applet Code

Here is the code that was compiled for the class file TextRepeaterApplet.class. Most of it should look familiar.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
 
public class TextRepeaterApplet extends JApplet implements ActionListener 
{
  JTextField source, destination;
  
  public void init() 
  {
    source = new JTextField("", 15);
    destination = new JTextField("", 15);
    
    setLayout(new FlowLayout() );
    add( new JLabel("Enter Your Name:") );
    add(source);
    add( new JLabel("Here is Your Name:") );
    add(destination);

    source.addActionListener( this );
    this.setBackground(Color.white);
  }
  
  public void actionPerformed( ActionEvent evt )  
  {
    destination.setText( source.getText() );
    repaint(); 
  }

}

The code is shorter than for the application because there is no need for a main() method.

QUESTION 16:

To run the applet, what must be done?