你需要下载导入JFREECHART的jar包
然后下面是一个例子
import orgjfreechartChartFactory;
import orgjfreechartChartPanel;
import orgjfreechartJFreeChart;
import orgjfreechartplotPlotOrientation;
import orgjfreedataxyXYSeries;
import orgjfreedataxyXYSeriesCollection;
import orgjfreeuiApplicationFrame;
import orgjfreeuiRefineryUtilities;
public class XYSeriesDemo extends ApplicationFrame {
/
A demonstration application showing an XY series containing a null value
@param title the frame title
/
public XYSeriesDemo(final String title) {
super(title);
final XYSeries series = new XYSeries("Random Data");
seriesadd(10, 5002);
seriesadd(50, 6941);
seriesadd(40, 1000);
seriesadd(125, 7344);
seriesadd(173, 4532);
seriesadd(212, 5002);
seriesadd(219, null);
seriesadd(256, 7344);
seriesadd(300, 4532);
final XYSeriesCollection data = new XYSeriesCollection(series);
final JFreeChart chart = ChartFactorycreateXYLineChart(
"XY Series Demo",
"X",
"Y",
data,
PlotOrientationVERTICAL,
true,
true,
false
);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanelsetPreferredSize(new javaawtDimension(500, 270));
setContentPane(chartPanel);
}
public static void main(final String[] args) {
final XYSeriesDemo demo = new XYSeriesDemo("XY Series Demo");
demopack();
RefineryUtilitiescenterFrameOnScreen(demo);
demosetVisible(true);
}
}
seriesadd(10, 5002);10,5002分别是横坐标和纵坐标数值 它会自动产生横竖坐标的
setDefaultCloseOperation 为JFrameHIDE_ON_CLOSE不行吗?
那试试把chartPanel显示在JFrame里吧,不用ApplicationFrame
以上就是关于Java如何调用数据库中的数据画图全部的内容,包括:Java如何调用数据库中的数据画图、JFreeChart ApplicationFrame实现隐藏关闭、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)