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:
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
}
Don’t add the chart panel into the main frame, add it to its content pane instead.
replace this.ji.add(cp);bythis.ji.getContentPane().add(cp)Or better:
In NetBeans, under the GUI editor (not code editor) add a panel into your main frame and call it something like
chartPanel. Add all other controls you want to display and position them as you like. Once done, switch back to code editor. On the main frame’s constructor, do the following: