Como posso corrigir esse código para adicionar este JFreeChart a um painel
Estou tentando criar um gráfico incorporado especificamente em um painel em umJInternalFrame
; é um gráfico de pizza da bibliotecaJFreeChart
. Quero incorporar o gráfico em um painel com o nome da variáveljpPaneles
, mas provou ser impossível. Isso é realmente crucial para o meu projeto, por isso, se alguém tiver tempo para me ajudar, eu agradeceria muito. Estou trabalhando no editor de interface gráfica do NetBeans. Aqui está o código e você pode ver que eu tento adicionar o frame1 a um paine
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
public class Eventad extends javax.swing.JInternalFrame {
public Eventad() {
initComponents();
}
public void updateChart() {
}
public static void main(String arg[]) {
DefaultPieDataset pieDataset = new DefaultPieDataset();
pieDataset.setValue("One", new Integer(10));
pieDataset.setValue("Two", new Integer(20));
pieDataset.setValue("Three", new Integer(30));
pieDataset.setValue("Four", new Integer(10));
pieDataset.setValue("Five", new Integer(20));
pieDataset.setValue("Six", new Integer(10));
JFreeChart chart = ChartFactory.createPieChart3D(
"3D Pie Chart", pieDataset, true, true, true);
PiePlot3D p = (PiePlot3D) chart.getPlot();
p.setForegroundAlpha(0.5f);
ChartFrame frame1 = new ChartFrame("3D Pie Chart", chart);
frame1.setVisible(true);
frame1.setSize(200, 200);
//Here im trying to add the frame1 to the Jpanel
this.jpPaneles.add(frame1);
}
}