HI, I try to create an applet with JfreeChart.
firstable, I have no problmes with it, it works fine when I use jfreechart and then jlabel.seticon(image)
however, now, I get problem when I try to make the chart move. for example, I like it the chart play as a heart pee line diagram. so it moves every one second. I put thread.sleep(1000)
and the applet only draw the first one chart and last chart. it skips all middle ones on the screen. (something I am sure, it does all process, but just doesn't show out on the screen)
how can I fix this? thank you
---------------------------example------------------------
public void setPoints()
{
series = new XYSeries("SLE Value", true);
xyDataset = new XYSeriesCollection(series);
//xyDataset.addSeries();
series.add(1200000000, 10.0);
series.add(1300000000, 20.0);
series.add(1400000000, 50.0);
series.add(1500000000, 10.0);
chart = ChartFactory.createTimeSeriesChart
("Time Chart", // Title
"Time", // X-Axis label
"H", // Y-Axis label
xyDataset, // Dataset
true // Show legend
);
image = chart.createBufferedImage(500,300);
jLabel1.setIcon(new ImageIcon(image));
}
public void setPoints2()
{
series.add(1600000000, 20.0);
series.add(1700000000, 50.0);
series.add(1800000000, 10.0);
series.add(1900000000, 20.0);
series.add(2000000000, 50.0);
chart = ChartFactory.createTimeSeriesChart
("Time Series Chart", // Title
"Time", // X-Axis label
"H", // Y-Axis label
xyDataset, // Dataset
true // Show legend
);
image = chart.createBufferedImage(500,300);
jLabel1.setIcon(new ImageIcon(image));
}
private void jButton1_actionPerformed(ActionEvent e)
{
try {
thread1.sleep(1000);
this.setPoints2();
thread1.sleep(1000);
this.setPoints();
}catch (Exception ei) {}
}
HELP: JfreeChart and thread in applet
Re: HELP: JfreeChart and thread in applet
You shouldn't put the main event thread to sleep, it will stop all screen updates. You need to create a separate thread to update your data.
One example is contained in this thread:
http://www.object-refinery.com/phorum-3 ... 353&t=3336
...with the demo applet here:
http://www.object-refinery.com/jfreechart/applet.html
Hope that helps...
Dave Gilbert
One example is contained in this thread:
http://www.object-refinery.com/phorum-3 ... 353&t=3336
...with the demo applet here:
http://www.object-refinery.com/jfreechart/applet.html
Hope that helps...
Dave Gilbert