Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to reload Applet automatically after spacific time?

843807Jul 11 2007
i have made a graph in applet which draw signal lines. i want applet show first line, after 1 second reload applet and draw second line preserving previous value.receiving values from a table having two fields 1.seconds...2.active_calls_count ..give dynamic sort of look...just like window's Task Manager-->Performance graph
code of Signal wave graph is below here..can anyone help me regarding this..

import java.applet.*;
import java.awt.*;

import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.*;
import java.awt.Color;
import java.sql.*;

public class SignalWave extends Applet
{
public void init()
{
setBackground(Color.WHITE);
setForeground(Color.BLUE);
}
/**Paint function is used to draw the graph on applet...*/
public void paint(Graphics g)
{
String query="select SEC,ACTIVE_CALLS_COUNT from bill.tbl_temp_calls";
xDatabase db=new xDatabase() ;
int temp=db.executeSQL(query,true);
if(temp<0)
{
//out.println("DataBase:ERROR");
}
int recCount=db.ResultSetRowCount() ;
//String sec=db.getStringVal(1);
//String active_calls=db.getStringVal(2) ;



Dimension d = getSize();
for(int i=0;i<recCount;i++)
{
g.drawLine(4,4,(int)db.getStringVal(1),(int)db.getStringVal(2)) ;

}
//for (int x = 0; x >< d.width; x++)
//{
//g.drawLine(x, 50 + (int) func(x), x + 1, 50 + (int) func(x + 1));
// }
}//end of paint method



/** This is the function that is plotted. */
double func(double x)
{
Dimension d = getSize();
double c;
c=(Math.cos(x / 25) + Math.sin(x / 18) + 4) * d.height / 8;

return c;
}//end of plot function
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2007
Added on Jul 11 2007
0 comments
118 views