Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Image refresh based to timer

Thread view: 
mikap79@hotmail.com - 06 Apr 2006 18:52 GMT
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;
   }
}
Oliver Wong - 06 Apr 2006 20:10 GMT
> Hi
>
[quoted text clipped - 3 lines]
>
> Thanks,

   There's a tutorial at
http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.