Solved the problem... Rewrote the code as follows...
import java.awt.*;
import javax.swing.*;
public class ttest extends JPanel implements Runnable
{
ttest()
{
JFrame j = new JFrame();
j.setBackground(Color.blue);
j.setSize(200,200);
j.add(this);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setVisible(true);
}
int i=10;
protected void paintComponent(Graphics g)
{
g.setColor(Color.RED);
g.setFont(new Font("Arial",1,20));
g.drawString("Hello",50,50);
g.drawString("me",i,i);
}
public void run()
{
while(true)
{
i+=20;
repaint();
System.out.println("Hello");
try{Thread.sleep(1000);}catch(Exception e){}
}
}
public static void main(String args[])
{
ttest tt = new ttest();
Thread t = new Thread(tt);
t.start();
}
}