Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.applet.*;
- public class runningname extends Applet implements Runnable{
- String msg,msg1;
- Thread t=null;
- int state;
- boolean stopflag;
- public void init()
- {
- setBackground(Color.yellow);
- setForeground(Color.red);
- }
- public void start()
- {
- msg="hi!this is bhushan ";
- msg1="this is first applet program ";
- if(msg==null)
- msg="plz write something in msg";
- msg=" "+msg;
- t=new Thread(this);
- stopflag=false;
- t.start();
- }
- public void run()
- {
- int i=1;
- char c,c1;
- while(i>0)
- {
- try{
- repaint();
- Thread.sleep(200);
- c=msg.charAt(0);
- c1=msg1.charAt(0);
- //System.out.println(c);
- msg=msg.substring(1, msg.length());
- msg1=msg1.substring(1, msg1.length());
- // System.out.println(" "+msg);
- msg+=c;
- msg1+=c1;
- if(stopflag)
- break;
- }catch(InterruptedException e)
- {
- System.out.println("error in printing");
- }
- }
- }
- public void stop()
- {
- t=null;
- stopflag=true;
- }
- public void paint(Graphics g)
- {
- g.drawString(msg, 50, 40);
- g.drawString(msg1, 50, 80);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment