This will be my second post. Many thanks to those who replied to my first questions.
I am using netbeans 5.5
I am attempting to run the following jFreeChart demo but in netbeans.
Original demo located here: http://www.java2s.com/Code/Java/Chart/JFreeChartPieChartDemo7.htm
Instead of programically creating the jPanel like the demo does, i would like to do it using the netbeans GUI and then add the code to create the jFreeChart.
In netbeans i create a new project, create a new jFrame and place a new jPanel on the form (keeping the variable name jPanel1) as illustrated below:
/*
* MainForm.java
*
* Created on June 28, 2007, 1:48 PM
*/
package mypkg;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
/**
*
* @author me
*/
public class MainForm extends javax.swing.JFrame {
/** Creates new form MainForm */
public MainForm() {
initComponents();
}
/** Netbeans Auto-Generated Code goes here which I have omitted */
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainForm().setVisible(true);
}
});
}
private void CreateChart() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Section 1", 23.3);
dataset.setValue("Section 2", 56.5);
dataset.setValue("Section 3", 43.3);
dataset.setValue("Section 4", 11.1);
JFreeChart chart3 = ChartFactory.createPieChart3D("Chart 3", dataset, false, false, false);
PiePlot3D plot3 = (PiePlot3D) chart3.getPlot();
plot3.setForegroundAlpha(0.6f);
plot3.setCircular(true);
jPanel1.add(new ChartPanel(chart3));
jPanel1.validate();
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
// End of variables declaration
}
I then attempted to call the CreateChart() function in several places (in the MainForm() function, in the pre and post creation code properties of the jPanel's properties dialog in netbeans (as well as pre and post init in the same screen)) and nothing seems to work. the program compiles and the jFrame comes up but the chart does not show.
If i run the example at the above noted link it runs fine in netbeans if i copy and paste the code directly, it just doesnt work when i try to get it to work through the netbeans GUI builder and the jPanel i create through it.
Can any more advanced netbeans/java users lend me a hand or point me in the right direction?
NOTE: in the code pasted above, i am only trying to run one of the four chart demo's listed in the original source in the link.
NOTE2: in the code pasted above it doesnt show me calling CreateChart() from anywhere, im hoping to get some advice on how to proceed from here.
Message was edited by:
amadman