×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Write a programme in java to accept a month name and print the month number. Programme to Compute Telegram Charge
Write a program to Blinking a Text using Applet. - Java
10304    Arnab De    14/06/2018

Write a program to Blinking a Text using Applet.

We have to import java.applet.* and java.awt.* package. This program done by the Thread. But as we already extends Applet class, we cannot extends another class called Thread. But we can implements the Runnable interface. Now initialised the thread object in init() method and start it in start() method. now overload the run() method to exchange the string and display it every 1 second. repaint() method is used to recall the paint() method with the new set of variables values.

softetechnologies
import java.awt.*;
import java.applet.*;

public class App1 extends Applet implements Runnable
{
    String msg;
    Thread th;
    public void init()
    {
       msg="Hello World";
       th=new Thread(this);
    }
    public void start(){
        th.start();
    }

    public void paint(Graphics g){g.drawString(msg,100,200);}

    public void run()
    {
        while(true)
        {
            if(msg.equals("Hello World"))
            {
                msg="";
            }
            else
            {
                msg="Hello World";
            }
            try{Thread.sleep(1000);}
            catch(Exception e){}
            repaint();
        }
    }
}
softetechnologies
blinking text applet
Blinking Text Applet
Write a programme in java to accept a month name and print the month number. Programme to Compute Telegram Charge
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Swami Vivekananda
Truth can be stated in a thousand different ways, yet each one can be true.
Swami Vivekananda
2346
64.28
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     47382
25/06/2018     39477
01/01/2018     39090
28/06/2017     36982
02/08/2017     35708
01/08/2017     29943
06/07/2017     29728
15/05/2017     29214
14/07/2017     25097
11/09/2018     24243
softetechnologies