changing the content of the jframe

i have a jTextField in a jFrame the content of this jTextField change every 3 seconds, but actually only the first value appear at the jTextField ,so how i can let the jTextField value increment ?
[210 byte] By [student14a] at [2007-11-27 2:38:25]
# 1
You are probably using a loop that contains Thread.sleep(...) which means the GUI can't repaint itself until the loop finishes executing.Use a [url http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html]Swing Timer[/url].
camickra at 2007-7-12 2:59:33 > top of Java-index,Desktop,Core GUI APIs...
# 2

thanx for ur advice, i used swing timer and it did what i need but a strange thing apears.

public class Visitor extends JPanel implements ActionListener{

staticjava.sql.Date date = new java.sql.Date((new java.util.Date()).getTime());

int in=0;

int out=0;

//int total=0;

Thread timer;

javax.swing.Timer t=new javax.swing.Timer(1000,this);

static Connection con;

public Visitor(){

t.restart();

}

public void paintComponent(Graphics g){

super.paintComponents(g);

if(t.isRunning()){

g.clearRect(10,10,50,50);

g.drawString(" "+peopleIN(),25,40);

}

}

public int peopleIN(){

int total=0;

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\project.mdb");

String sql = "SELECT SUM(INN) AS TOTAL,SUM(OUT) AS TOTAL1 FROM Stat WHERE Event_date = ?";

PreparedStatement ps = con.prepareStatement(sql);

ps.setDate(1, date);

ResultSet rs = ps.executeQuery();

while(rs.next()){

in=rs.getInt(1);

out=rs.getInt(2);

total=in-out;

//System.out.println("azzzzzzzzzz"+jj+"zza"+i+"\n"+"Totalllllllll"+total);

}

}catch(ClassNotFoundException e){

System.out.println(e.toString());

}

catch(SQLException e){

System.out.println(e.toString());

}

System.out.println(""+total);

return total;

}

public void actionPerformed(ActionEvent a) {

repaint();

}

i called this class at another frame and the Jpanel apears correctly but above it apears component of the frame, so what is the problem?

student14a at 2007-7-12 2:59:33 > top of Java-index,Desktop,Core GUI APIs...