×
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
10978    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
Education is not the learing of facts, but the training of the mind to think.
Albert Einstein
3428
81.14
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     54175
25/06/2018     45159
01/01/2018     43710
28/06/2017     41239
02/08/2017     40262
01/08/2017     34303
06/07/2017     34099
15/05/2017     33354
11/09/2018     30383
14/07/2017     29874
softetechnologies