我创建了JFreeChart并将其放入chartpanel(如建议的那样)。我还将它添加到jPanel。我正在使用jFrame。但是在运行程序后我的图表不可见。有人可以帮帮我吗?
final JFreeChart chart = ChartFactory.createXYLineChart(
"XY Series Demo",
"iterácie",
"%",
data,
PlotOrientation.VERTICAL,
true,
true,
false
);
final ChartPanel chartPanel = new ChartPanel(chart);
//chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
chartPanel.setDomainZoomable(true);
chartPanel.setVisible(true);
jPanel1.add(chartPanel, BorderLayout.CENTER);
答案 0 :(得分:0)
(在问题编辑中回答。转换为社区维基回答。请参阅What is the appropriate action when the answer to a question is added to the question itself?)
OP写道:[求助]我错过了这两个:
jPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.validate();