×
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
10002    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.
Sri Sri Ramakrishna Paramahamsa
Have love for everyone, no one is other than you.
Sri Sri Ramakrishna Paramahamsa
870
58.53
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     44001
01/01/2018     36614
25/06/2018     35919
28/06/2017     34654
02/08/2017     33153
01/08/2017     27623
06/07/2017     27341
15/05/2017     26989
14/07/2017     22634
21/04/2018     21243
softetechnologies