/home/wpollock1/public_html/AJava/SignedCodeDemo/MyApplet.java

// Signed MyApplet Demo - A simple Applet, signed.
// Once signed, the user can allow extra permissions for any applet
// (or WebStart) program.
//
// Written 8/2013 by Wayne Pollock, Tampa Florida USA
// Updated 2/2015 by WP: Fixed swing GUI creation to use EDT.
//                       Updated to use Java 8 method reference.
// From original code by D. Liang (supplement to 9th ed of his book).

package mypackage;

import java.io.*;
import javax.swing.*;

public class MyApplet extends JApplet {
   public void init () {
      // Create this JApplet's GUI on the event-dispatching thread:
      try {
         SwingUtilities.invokeAndWait( this::createGUI );
      } catch ( Exception e ) {
         System.err.println("createGUI didn't successfully complete");
      }
   }

   private void createGUI() {
      JLabel label = new JLabel();
      add( label );

      // The following code causes a security exception in an applet,
      // even if signed, if it runs in the "sandbox".  However, the
      // user can grant a signed applet extra (all) permissions; in fact,
      // that is the default for signed applets since Java 7U10.

      try {
         File file = new File( "." );
         label.setText( "The current directory is "
            + file.getAbsolutePath() );
      } catch ( Exception e ) {
         e.printStackTrace();
         label.setText(
            "Security exception while attempting access to current directory" );
      }
   }
}