Hi,
I am starting to create the first my chart using JFreeChart.
I am a new Java Programer and I try to cheach myself Java. I am make the final project for University. Please Help me.
My Aplet look like:
package Chart_Pagkage;
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.*;
import java.applet.*;
import javax.swing.JApplet;
import org.jfree.chart.*;
import org.jfree.data.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.entity.EntityCollection;
import org.jfree.chart.entity.PieSectionEntity;
import org.jfree.chart.labels.StandardPieItemLabelGenerator;
import org.jfree.data.DatasetUtilities;
import org.jfree.data.PieDataset;
public class Chart1 extends Applet implements Runnable
{
public Chart1()
{
}
public void init()
{
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(10.0));
data.setValue("C/C++", new Double(17.5));
data.setValue("PHP", new Double(32.5));
data.setValue("Perl", new Double(12.5));
// create the chart...
JFreeChart chart = ChartFactory.createPie3DChart("program language",data, true, false, false);
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(270);
plot.setForegroundAlpha(0.5f);
// add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 370));
setLayout( new FlowLayout() );
add(chartPanel);
}
public static void main(String[] args)
{
Chart1 applet = new Chart1();
Frame frame = new Frame();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.add(applet, BorderLayout.CENTER);
frame.setTitle("Applet Frame");
applet.init();
applet.start();
frame.setSize(300, 300);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
frame.setLocation((d.width - frameSize.width) / 2, (d.height - frameSize.height) / 2);
frame.setVisible(true);
}
private void jbInit() throws Exception
{
this.setLayout(null);
}
public void destroy()
{
System.exit(0);
}
}
And the Error are:
Error(14,1): cannot access directory org\jfree\chart; verify that directory is reachable from classpath and/or sourcepath
...
Error(19,31): cannot access class org.jfree.chart.labels.StandardPieItemLabelGenerator; file org\jfree\chart\labels\StandardPieItemLabelGenerator.class not found
...
Error(23,8): class Chart_Pagkage.Chart1 should be declared abstract; it does not define method run() in interface java.lang.Runnable
...
Error(31,5): class DefaultPieDataset not found in class Chart_Pagkage.Chart1
...
Error(40,24): variable ChartFactory not found in class Chart_Pagkage.Chart1
...
Looking for your helps.
Thanks a lot