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 graphical reports from the data (easy thing ...). My question is as follows, I'm using the JFreeChart library which is responsible for creating the graphics, I've taken a basic example to understand how it works and it's pretty simple except it did not work.
I created a JFrame
with a JPanel
and a button, in 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;
Thanks in advance!