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;
}
}
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;
}
}