COP 2800 (Java Programming I) Homework Assignment #8

 

Due: by the start of class on the date shown on the syllabus

Description:

Answer the following questions as briefly (but completely) as possible:

  1. Is javax.swing.JApplet a subclass of java.applet.Applet?
  2. Describe the <applet> HTML tag.  How do you embed an applet in a web page using this tag?  List some alternatives to using the <applet> tag for applets.
  3. List some security restrictions on applets.  What is an alternative to applets, that can still load Java programs from the Internet?
  4. Can you create a Frame (or JFrame) from an Applet (or JApplet)?
  5. Why does the applet below display nothing?
    import javax.swing.*;
    
    public class WelcomeApplet extends JApplet {
       public WelcomeApplet () {
          JLabel jlblMessage = new JLabel( "It is Java" );
       }
    }
  6. Why does the applet below display a runtime NullPointerException on line 12 (shown as highlighted)?
    import javax.swing.*;
    
    public class WelcomeApplet extends JApplet {
       JLabel jlblMessage;
       
       public WelcomeApplet () {
          JLabel jlblMessage = new JLabel( "It is Java" );
       }
       
       @Override
       public void init () {
          add( jlblMessage );
       }
    }
  7. How do you pass parameters to applets, using the <applet> tag?
  8. How do you create an ImageIcon from the file image/us.gif (where image is a sub-directory of the directory containing your Java classes)?
  9. How do you create an AudioClip from the file anthem/us.mid (where anthem is a sub-directory of the directory containing your Java classes)?

To be turned in:

Email your homework assignment, by copy-and-paste (no attachments please), to (homework submission).  If possible use the “text” and not the “HTML” mode of your email program.  Please use the subject similar to “Java Programming I Homework Assignment #8 Submission”, so I can tell which emails are submitted homework assignments.

Homework assignments will not be returned.  Please do not send as attachments.  Refer to the Homework and the Submitting Assignments sections of your syllabus for more information.

Confused?  Send questions about the homework assignment to (homework questions).  Please use a subject similar to “Java Programming I Homework Assignment #8 Questions” so I can tell which emails are questions about assignment quiz (and not submissions).