Fiz um programa em java em que uso o jfreechart pra gerar um gráfico, porém quando eu crio o .jar do programa o gráfico não aparece.
Me Ajudem por favor
A Classe do Gráfico
package graficos;
import java.awt.Color;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.XYLineAndShapeRenderer;
import org.jfree.data.XYDataset;
import org.jfree.data.XYSeries;
import org.jfree.data.XYSeriesCollection;
import view.jnlMemoria;
public class GeraGraficoXY extends JFrame
{
private static final long serialVersionUID = 1L;
@SuppressWarnings("deprecation")
public GeraGraficoXY(int[] array1,int[] array2,int[] array3,int[] array4){
final XYDataset dataset = createDataset(array1,array2,array3,array4);
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setSize(300,370);
chartPanel.setVisible(true);
chartPanel.setLayout(null);
jnlMemoria.jPanel1.add(chartPanel);
jnlMemoria.jPanel1.updateUI();
}
private JFreeChart createChart(final XYDataset dataset) {
// create the chart...
final JFreeChart chart = ChartFactory.createXYLineChart(
"Acertos X Frames", // chart title
"Frames", // x axis label
"Acertos", // y axis label
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customisation...
final XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesShapesVisible(0, true);
renderer.setSeriesShapesVisible(1, true);
renderer.setSeriesShapesVisible(2, true);
renderer.setSeriesShapesVisible(3, true);
plot.setRenderer(renderer);
// change the auto tick unit selection to integer units only...
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// OPTIONAL CUSTOMISATION COMPLETED.
return chart;
}
private XYDataset createDataset(int[] array1,int[] array2,int[] array3,int[] array4) {
int armazena = jnlMemoria.primeiro_frame;
final XYSeries series1 = new XYSeries("FIFO");
for(int i=0; i<array1.length; i++){
series1.add(armazena, array1[i]);
armazena++;
}
armazena = jnlMemoria.primeiro_frame;
final XYSeries series2 = new XYSeries("MRU");
for(int i=0; i<array2.length; i++){
series2.add(armazena, array2[i]);
armazena++;
}
final XYSeries series3 = new XYSeries("NUR");
for(int i=0; i<array3.length; i++){
series3.add(armazena, array3[i]);
armazena++;
}
final XYSeries series4 = new XYSeries("Segunda Chance");
for(int i=0; i<array4.length; i++){
series4.add(armazena, array4[i]);
armazena++;
}
final XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
dataset.addSeries(series3);
dataset.addSeries(series4);
return dataset;
}
}