How to add a Jfreechart(pie chart) to a panel in netbeans

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Rayden150
Posts: 1
Joined: Sun Nov 20, 2011 7:28 pm
antibot: No, of course not.

How to add a Jfreechart(pie chart) to a panel in netbeans

Post by Rayden150 » Sun Nov 20, 2011 7:30 pm

Im using netbeans gui editor and im trying to add a Jfreechart that is itself in a internal frame, and this internal frame I am wanting to add it to a panel, as you can see in this image (sorry I cant post image directly because im a newbie):

http://www.flickr.com/photos/63259070@N06/6370734167/

The internal frame doesn't even show up on the panel "Estadisticas" when I run it, I think its harder because im not doing the gui by code but it shouldn't be that hard, If anyone could help me add this properly I would greatly appreciate it, here is the code that I have been trying out:

Code: Select all

 private void display() {
       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);
    ChartPanel cp = new ChartPanel(chart);
     //  JInternalFrame jif = new JInternalFrame(
     //   "Chart", true, true, true, true);
    this.ji.add(cp); //ji is the name of the internal frame
    this.ji.pack();
    this.ji.setVisible(true);
    this.ji.setSize(100, 100);

    JDesktopPane dtp = new JDesktopPane();
    dtp.add(ji);
    this.jpEstadisticas.add(dtp);   //jpEstadisticas the name of the main "Estadisticas"panel

}

chunkyks
Posts: 8
Joined: Sat Sep 24, 2011 2:56 am
antibot: No, of course not.

Re: How to add a Jfreechart(pie chart) to a panel in netbean

Post by chunkyks » Mon Nov 28, 2011 6:19 am

Personally, I choose "custom code" for a JPanel's constructor in the netbeans gui editor. Then simply give a function that I create that returns a JChartPanel. NetBeans does everything else for me, that way.

Gary (-;

Locked