×
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
10519    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
One cannot be spiritual as long as one has shame, hatred, or fear.
Sri Sri Ramakrishna Paramahamsa
1373
69.48
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     50608
25/06/2018     42596
01/01/2018     41778
28/06/2017     39560
02/08/2017     38349
01/08/2017     32573
06/07/2017     32270
15/05/2017     31726
14/07/2017     27859
11/09/2018     27598
softetechnologies