用java写了个applet程序,在jsp上运行时总报Runtimeexception,这是什么情况。。。 10
java代码如下:packagecom.hundsun.jfreechart;publicclassAbcdextendsJApplet{privatestaticfin...
java代码如下:
package com.hundsun.jfreechart;
public class Abcd extends JApplet {
private static final long serialVersionUID = 3257566209007171634L;
private double cpuValue1;
private double cpuValue2;
private double cpuValue3;
private TimeSeries cpu1;
private TimeSeries cpu2;
private TimeSeries cpu3;
/**
* 内部类--实现动态随机产生虚拟CPU使用率的值
* @author tf
*
*/
public class DataGenerator extends Timer implements ActionListener {
private static final long serialVersionUID = 3977867288743720505L;
public void actionPerformed(ActionEvent actionevent) {
cpuValue1 = 100;
cpuValue2 = 100;
cpuValue3 = 100;
double d1 = Math.random();
cpuValue1 = cpuValue1 * d1;
double d2 = Math.random();
cpuValue2 = cpuValue2 * d2;
double d3 = Math.random();
cpuValue3 = cpuValue3 * d3;
addcpu1Observation(cpuValue1);
addcpu2Observation(cpuValue2);
addcpu3Observation(cpuValue3);
}
DataGenerator() {
super(100, null);
addActionListener(this);
}
}
public Abcd() {
cpu1 = new TimeSeries("处理器1", Millisecond.class);//增加一条走势曲线
cpu2 = new TimeSeries("处理器2", Millisecond.class);
cpu3 = new TimeSeries("处理器3", Millisecond.class);
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
//将所有走势曲线加入到时间条中
timeseriescollection.addSeries(cpu1);
timeseriescollection.addSeries(cpu2);
timeseriescollection.addSeries(cpu3);
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("处理器利用率",
"时间", "值(%)", timeseriescollection, true, true, true);
XYPlot xyplot = jfreechart.getXYPlot();
// xyplot.setOutlinePaint(Color.CYAN);//设置数据区的边界线条颜色
ValueAxis valueaxis = xyplot.getDomainAxis();
// valueaxis.setAutoRange(true); //自动设置数据轴数据范围
valueaxis.setFixedAutoRange(10000D);//设置时间轴显示的数据
valueaxis = xyplot.getRangeAxis();
valueaxis.setRange(0.0D, 100D);//数据轴固定数据范围(设置100的话就是显示MAXVALUE到MAXVALUE-100那段数据范围)
// valueaxis.setAutoRange(true);
valueaxis.setVisible(true);//设置是否显示数据轴
//设置曲线图面版
ChartPanel chartpanel = new ChartPanel(jfreechart);
chartpanel.setPopupMenu(null);
ChartPanel chartpanel1 = new ChartPanel(jfreechart);
chartpanel1.setPopupMenu(null);
getContentPane().add(chartpanel);
getContentPane().add(chartpanel1);
(new DataGenerator()).start();
}
private void addcpu1Observation(double d) {
cpu1.add(new Millisecond(), d);
}
private void addcpu2Observation(double d) {
cpu2.add(new Millisecond(), d);
}
private void addcpu3Observation(double d) {
cpu3.add(new Millisecond(), d);
}
} 展开
package com.hundsun.jfreechart;
public class Abcd extends JApplet {
private static final long serialVersionUID = 3257566209007171634L;
private double cpuValue1;
private double cpuValue2;
private double cpuValue3;
private TimeSeries cpu1;
private TimeSeries cpu2;
private TimeSeries cpu3;
/**
* 内部类--实现动态随机产生虚拟CPU使用率的值
* @author tf
*
*/
public class DataGenerator extends Timer implements ActionListener {
private static final long serialVersionUID = 3977867288743720505L;
public void actionPerformed(ActionEvent actionevent) {
cpuValue1 = 100;
cpuValue2 = 100;
cpuValue3 = 100;
double d1 = Math.random();
cpuValue1 = cpuValue1 * d1;
double d2 = Math.random();
cpuValue2 = cpuValue2 * d2;
double d3 = Math.random();
cpuValue3 = cpuValue3 * d3;
addcpu1Observation(cpuValue1);
addcpu2Observation(cpuValue2);
addcpu3Observation(cpuValue3);
}
DataGenerator() {
super(100, null);
addActionListener(this);
}
}
public Abcd() {
cpu1 = new TimeSeries("处理器1", Millisecond.class);//增加一条走势曲线
cpu2 = new TimeSeries("处理器2", Millisecond.class);
cpu3 = new TimeSeries("处理器3", Millisecond.class);
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
//将所有走势曲线加入到时间条中
timeseriescollection.addSeries(cpu1);
timeseriescollection.addSeries(cpu2);
timeseriescollection.addSeries(cpu3);
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("处理器利用率",
"时间", "值(%)", timeseriescollection, true, true, true);
XYPlot xyplot = jfreechart.getXYPlot();
// xyplot.setOutlinePaint(Color.CYAN);//设置数据区的边界线条颜色
ValueAxis valueaxis = xyplot.getDomainAxis();
// valueaxis.setAutoRange(true); //自动设置数据轴数据范围
valueaxis.setFixedAutoRange(10000D);//设置时间轴显示的数据
valueaxis = xyplot.getRangeAxis();
valueaxis.setRange(0.0D, 100D);//数据轴固定数据范围(设置100的话就是显示MAXVALUE到MAXVALUE-100那段数据范围)
// valueaxis.setAutoRange(true);
valueaxis.setVisible(true);//设置是否显示数据轴
//设置曲线图面版
ChartPanel chartpanel = new ChartPanel(jfreechart);
chartpanel.setPopupMenu(null);
ChartPanel chartpanel1 = new ChartPanel(jfreechart);
chartpanel1.setPopupMenu(null);
getContentPane().add(chartpanel);
getContentPane().add(chartpanel1);
(new DataGenerator()).start();
}
private void addcpu1Observation(double d) {
cpu1.add(new Millisecond(), d);
}
private void addcpu2Observation(double d) {
cpu2.add(new Millisecond(), d);
}
private void addcpu3Observation(double d) {
cpu3.add(new Millisecond(), d);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询