×
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
11057    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.
Albert Einstein
It is the supreme art of the teacher to awaken joy in creative expression and knowledge.
Albert Einstein
5204
83.33
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     54537
25/06/2018     45628
01/01/2018     43953
28/06/2017     41463
02/08/2017     40566
01/08/2017     34555
06/07/2017     34330
15/05/2017     33570
11/09/2018     30889
14/07/2017     30360
softetechnologies