import java.awt.*; import java.awt.event.*; import java.applet.*; public class Twoo extends Frame implements Runnable { private int x; private int y; Thread t1; public Twoo(String title) { super(title); t1 = new Thread(this,"thread1"); t1.start(); x=590; y=0; } public void run() { while (true) { try { x--; y++; Thread.sleep(10); repaint(); if(x==0 && y==590){ for(int i=0 ; i< 590;i++){ x++; y--; Thread.sleep(10); repaint(); } } } catch (InterruptedException ie) { ie.printStackTrace(); } } } public void paint(Graphics g) { g.setColor(Color.blue); g.setFont(new Font("Arial",Font.BOLD|Font.ITALIC,20)); g.drawString("Mumbai, Rohan Maharashtra",x,300); g.drawString("Mumbai, Maharashtra",y,300); g.drawString("Mumbai, Maharashtra",200,x); g.drawString("Mumbai, Maharashtra",200,y); } public static void main(String[] args) { Frame f=new TwoString("My Thread Frame"); f.setSize(800,500); f.setVisible(true); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)