how to make button move in a sigle row
import java.awt.*;Here is my code for moving button in a single row , but the problem i m facing is that it is moving very fast i want that to move per second means button move forward after each second...
import java.applet.*;
public class fi extends Applet implements Runnable
{
Button b[] = new Button[1];
int x1=0;
Thread t;
public void init()
{
for(int i=0;i<1;i++)
{
setLayout(new FlowLayout());
b = new Button();
add(b);
}
}
public void start()
{
t = new Thread(this);
t.start();
}
public void run()
{
Thread t1=Thread.currentThread();
while(t==t1)
{
try
{
repaint();
Thread.sleep(1000);
setBackground(Color.blue);
}
catch(Exception e){}
}
}
public void paint(Graphics g)
{
for (int j=0;j<1;j++)
{
b[j].setSize(15,6);
x1=(x1+3)%200;
b[j].setLocation(x1,100);
}
}
}
/*<applet code="fi.class" width="300" height="400"></applet>*/
Is this my code correct or need some more implementation or us there any another way to approach this...