JCharts in applets

"Leonid Asanov" <[email protected]> Thu, 01 Apr 2004 11:23:30 +1000
Newsgroups gmane.comp.krysalis.jcharts.user
Message-ID <[email protected]>
I'm trying to adapt SwingDemo for working within JApplet, but can't make it 
display anything.
Could you look at my code and tell what is wrong with it?
Thank you!

____

import org.jCharts.chartData.ChartDataException;
import org.jCharts.chartData.PieChartDataSet;
import org.jCharts.nonAxisChart.PieChart2D;
import org.jCharts.properties.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.image .*;


public class AppletTest extends JApplet
{
	private JPanel panel;
	private PieChart2D pieChart2D;
	private BufferedImage bufferedImage;

	public AppletTest() {
	try {
		initComponents();
	} catch(Exception e) {};
	}

	public void init() {
		this.panel.getGraphics().drawImage(bufferedImage,0,0,this);
	}

	public void start() {
//		this.panel.getGraphics().drawImage(bufferedImage,0,0,this);
	}


	public void initComponents() throws ChartDataException, PropertyException
	{
		this.panel=new JPanel( true );
		this.panel.setSize( 500, 500 );
		this.getContentPane().add( this.panel );

		String[] labels={"BMW", "Audi", "Lexus"};
		String title="Cars that Own";
		Paint[] paints={Color.blue, Color.gray, Color.red};
		double[] data={50d, 30d, 20d};

		PieChart2DProperties pieChart2DProperties=new PieChart2DProperties();
		PieChartDataSet pieChartDataSet=new PieChartDataSet( title, data, labels, 
paints, pieChart2DProperties );

		pieChart2D=new PieChart2D( pieChartDataSet, new LegendProperties(), new 
ChartProperties(), 450, 450 );

		bufferedImage=new BufferedImage( 450, 450, BufferedImage.TYPE_INT_RGB );
		pieChart2D.setGraphics2D( bufferedImage.createGraphics() );
		pieChart2D.render();
	}
}


Regards,
Leo Asanov

_________________________________________________________________
Personalise your phone with chart ringtones and polyphonics. Go to  
http://ringtones.com.au/ninemsn/control?page=/ninemsn/main.jsp



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click