title: How to call an applet method from JavaScript
body: <p>I have created an applet and I am going to access an applet method from my HTML page on a web project.</p>
  <p>Here my applet looks like:</p>
  <pre><code>public class MessageApplet extends Applet {
  
      private Label m_mess;
  
      public void init()
      {
          setBackground(Color.lightGray);
          setLayout(new BorderLayout());
          m_mess = new Label(&quot;MessageApplet is Running...: No Selection Yet&quot;, Label.CENTER);
          add(BorderLayout.CENTER, m_mess);
      }
  
      public void setMessage(String message)
      {
          m_mess.setText(&quot;Selection: &quot; + message);
      }
  }
  </code></pre>
  <p>And my HTML page looks like:</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
      &lt;title&gt;Insert title here&lt;/title&gt;
      &lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;
          function selectedCity()
          {
              if(document.CityChoice.City[0].checked == true)
              {
                  document.SimpleMessageApplet.setMessage(document.CityChoice.City[0].value);
              }
          }
      &lt;/SCRIPT&gt;
  &lt;/HEAD&gt;
  
  &lt;BODY&gt;
      &lt;b&gt;This is the applet&lt;/b&gt;
      &lt;APPLET 
          CODE=&quot;MessageApplet.class&quot; 
          NAME=&quot;SimpleMessageApplet&quot; 
          WIDTH=350
          HEIGHT=100&gt;
      &lt;/APPLET&gt;
      &lt;FORM NAME=&quot;CityChoice&quot;&gt;
          &lt;input type=&quot;radio&quot; name=&quot;City&quot; value=&quot;Boston&quot; onClick=&quot;selectedCity()&quot;&gt; Boston&lt;br&gt;
      &lt;/form&gt;
  &lt;/BODY&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>But when I click radio button my browser hangs and I cannot access the applet method ever.</p>
  <p>My applet class is in default directory and HTML is in WebContent folder. What should I change in my code?</p>