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?