Search code examples
applet

How to refresh Java Applet?


I'm trying to use Java Applet for my website. but I have a problem with refresh java applet content.

here is my code, (AppletTest.java)

import java.applet.*;
import java.awt.*;


public class AppletTest extends Applet{

    public void init(){

    }

    public void stop(){

    }

    public void paint(Graphics g){
        g.drawString("ABC",20,20); //I will draw DEF and FFF after ABC.
    }

}

and HTML is (appletTest.html)

 <body>
  <applet code="AppletTest.class" name='AppletTest' width='500' height='300' style='border:1px solid #cdcdcdl'>
    <param name='cache_option' value='no'> // I put this code to avoid browser remember applet but it does not work. :(
  </applet>
 </body>

Firstly I draw 'ABC' and It draw well.

and I change 'ABC' to 'DEF' and compile again and run it.

it draw 'DEF' well. And I change 'DEF' to 'FFF' and compile and run.

but it does not change to 'FFF'. it still 'DEF'. I refresh the page many time but it is not changed.

I think my browser remember pre applet content. so to avoid it, I put the <param name='cache_option' value='no'> code into applet tag. but it does not work...

anybody know this, please advice me.

Thank you!


Solution

  • Applets should be tested in tools like applet viewer or Appleteer, which do not cache classes. If testing in a browser, ensure the Java Console is open (there is an option in the Java Control Panel) & type Ctrl-X (I think that is 'clear class cache') before refreshing the page.


    I put the <param name='cache_option' value='no'> code into applet tag..

    That only works with recent JREs. What JRE version has the user got installed?