Java-Text Moving Animation

Program Program Source import java.applet.Applet; import java.awt.Graphics; import java.awt.Color; import java.awt.Font; public class Javaapp extends Applet implements Runnable{ private String msg = “123456789”; private Thread t; public void start() { t = new Thread(this,”Animation”); t.start(); } public void run() { for(;;) { try{ Thread.sleep(2000); }catch(InterruptedException ex){} msg +=msg.charAt(0); msg = msg.substring(1,msg.length()); repaint(); } } public … Read more…

Java-Stop and Destroy

Stop The stop( ) method is called by the web browser or the appletviewer to suspend the execution of an applet. When a user switches over from a web page that contains the applet to another web page, the execution of that web page will be suspended. Remember that the stop( ) method will be … Read more…

Java-Repaint

Repaint The Repaint( ) method is used to repaint the window. Program Program Source import java.applet.Applet; import java.awt.Graphics; public class Javaapp extends Applet { int i; public void paint(Graphics g) { g.drawString(“i = “+i, 100, 100); try{ Thread.sleep(1000); }catch(InterruptedException ex){} i++; repaint(); } }

Java-Repeated Execution of Start and Paint

Repeated Execution of Start and Paint The init() method to be executed only once. But the start() method called every time whenever the execution of an applet is to be resumed. Program Prorgam Source import java.applet.Applet; import java.awt.Graphics; public class Javaapp extends Applet { String str = “”; public void init() { str+=”-init-“; } public void … Read more…

Java-Init and Start

Init The init( ) method is the first method to be called. The init( ) method is called by the browser when the applet begins execution. This method is called only once during the run time of your applet. start The start( ) method is executed after the init( ) method completes its execution. This method … Read more…

Java-Repeated Execution of Paint

Repeated Execution of Paint The paint( ) method is automatically called by the appletviewer or the web browser whenever the applet needs to be refreshed. The paint method is called each time of your applet’s must be redrawn. For example the applet window is minimized and then maximized, paint( ) is also called when the … Read more…