2
Hello, I’m developing a Java swing application for a university project. Basically it is a program that reads XML files from another application (mobile game) and generates graphic reports from the data (easy thing...). My question is the following, I am using the Jfreechart library that is responsible for creating the charts, I took a basic example to understand how it works and it is quite simple, except for not having worked.
I created a JFrame
with a JPanel
and a button, on the button I put the following code:
DefaultPieDataset dpd = new DefaultPieDataset();
dpd.setValue("Valor 1", 10);
dpd.setValue("Valor 2", 20);
dpd.setValue("Valor 3", 30);
dpd.setValue("Valor 4", 40);
JFreeChart grafico = ChartFactory.createPieChart("Nome do Grafico", dpd, true, true, true);
ChartPanel chartPanel = new ChartPanel(grafico);
primeiroGrafico.add(chartPanel);
primeiroGrafico.validate();
But the chart does not appear inside the panel!?
These are the namespaces:
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
From now on, thank you!
Thanks! I created a new project and it worked, now I need to see why it doesn’t work in the previous project! more thank you!
– Hebert Lima