Image refresh based to timer

Discussion in 'Java' started by mikap79@hotmail.com, Apr 6, 2006.

  1. Guest

    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;
    }
    }
     
    , Apr 6, 2006
    #1
    1. Advertising

  2. Oliver Wong Guest

    Oliver Wong, Apr 6, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelsang Wangchuk

    System.Timers.Timer vs. System.Threading.Timer

    Kelsang Wangchuk, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    730
    Kelsang Wangchuk
    Jul 31, 2003
  2. Jim Hammond

    server-side timer vs. meta refresh

    Jim Hammond, Oct 24, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    5,919
    mikeb
    Oct 27, 2003
  3. Replies:
    1
    Views:
    1,640
    Steve C. Orr [MVP, MCSD]
    Feb 22, 2005
  4. Simon

    page timer, or redirect timer

    Simon, Nov 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    11,233
    Bruce Barker
    Nov 4, 2005
  5. Replies:
    8
    Views:
    562
    Jorgen Grahn
    Jul 15, 2013
Loading...

Share This Page