I am trying to make a chart that is embedded specifically in a panel on a JInternalFrame
; it is a pie chart from the library JFreeChart
. I want to embed the chart on a panel which goes by the variable name jpPaneles
, but it has proven to be impossible. This is really crucial for my project, so if anyone has the time to help me out, I would greatly appreciate it. I am working in NetBeans GUI editor. Here is the code and you can see I try to add frame1 to a panel.
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);
}
}