into applet

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Guest233

into applet

Post by Guest233 » Thu Oct 06, 2005 7:56 am

hi all,can any gentleman turn this swing program into applet.Pls help
I am not regular java programmer.i need this on uregent

Thnx in advance.

Code: Select all

import javax.swing.*;
import java.lang.String;
import org.jfree.chart.*;
import org.jfree.data.xy.*;
import org.jfree.data.*;
import java.awt.image.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.xy.*;
                                                                                                                                                                                                         
public class LineGraph extends JPanel implements Runnable{
                                                                                                                                                                                                         
        JFreeChart innochart;
        XYDataset innoDataset;
        XYSeries innoSeries;
        JLabel innoLabel;
        Thread thread;
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                                                                                                                                                                                                         
        public LineGraph()
        {
                this.setBackground(java.awt.Color.white);
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                innoLabel = new JLabel();
                this.add(innoLabel);
                                                                                                                                                                                                         
                thread = new Thread(this);
                thread.start();
        }
                                                                                                                                                                                                         
        double i = 0;
        public void run(){
                //xy  series for a inno
                innoSeries = new XYSeries("Network");
                                                                                                                                                                                                         
                for(i = 0; i < 6; i = i + 0.1)
                {
                         innoSeries.add(i, java.lang.Math.random());
                }
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                                                                                                                                                                                                         
        while (true) {
                                                                                                                                                                                                         
        if(i < 6)
                {
                        //adding random data to graph
                         innoSeries.add(i, java.lang.Math.random() );
                         innoSeries.add(i+0.1, 0 );
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                        i =  i + 0.1;
                }
 if(i >= 6)
                {
                        i =0.0;
                }
                                                                                                                                                                                                         
                innoDataset = new XYSeriesCollection(innoSeries);
                                                                                                                                                                                                         
                innochart = ChartFactory.createXYAreaChart
                                     ("NETWORK USAGE",              // Title
                                      "X",            // X-Axis label
                                      "Y",           // Y-Axis label
                                      innoDataset,      // Dataset
                                      org.jfree.chart.plot.PlotOrientation.VERTICAL,
                                      true,             // Show legend
                                      true,
                                      true
                                     );
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                //change the color of the plot
                XYPlot plot = innochart.getXYPlot();
                XYAreaRenderer rr = (XYAreaRenderer) plot.getRenderer();
                rr.setSeriesPaint(0, new java.awt.Color(155, 155, 192));
                                                                                                                                                                                                         
                innochart.setBackgroundPaint(java.awt.Color.white);
                                                                                                                                                                                                         
                BufferedImage image = innochart.createBufferedImage(400,180);
                                                                                                                                                                                                         
                innoLabel.setIcon(new ImageIcon(image));
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                                                                                                                                                                                                         
                                                                                                                                                                                                         
            try {
                thread.currentThread().sleep(3000);
            } // End of try.
            catch(InterruptedException e) {
                } // End of catch.
            repaint();
        }
        }
                                                                                                                                                                                                         
                                                                                                                                                                                                         
        public static void main (String args[]){
                                                                                                                                                                                                         
                LineGraph panel = new LineGraph();
                JFrame frame = new JFrame();
                frame.setSize(500,400);
                frame.getContentPane().add(panel);
                frame.setVisible(true);
        }
                                                                                                                                                                                                         
}

michael75
Posts: 16
Joined: Thu Sep 15, 2005 4:42 pm

Post by michael75 » Thu Oct 06, 2005 7:42 pm

just rotfl... this is not a general purpose 'solve my problem' forum... as this has nothing to do with the core of jfreechart, don't expect anyone to reply in a different way as i did...

Locked