Image refresh based to timer

M

mikap79

Hi

I'm new with Java. My problem is how to refresh image on applet canvas
based on timer.
How to repaint canvas every 5sec by using Java.util timer?

Thanks,

-Mike


package untitled7;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.image.*;




public class Applet1 extends Applet {
Image myimage=null;


boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();

//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}

//Construct the applet
public Applet1() {

}

//Initialize the applet
public void init() {
try {
jbInit();

} catch (Exception e) {
e.printStackTrace();
}
}


public void paint(Graphics g) {

myimage = getImage(getCodeBase(),"logo.gif");

g.drawImage(myimage, 10, 10, this);
}

//Component initialization
private void jbInit() throws Exception {
}

//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}

//Get parameter info
public String[][] getParameterInfo() {

return null;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top