
hi........
I am able to get the output of bar graph. but now i want that to be displayed on my own form. The code which i am having in that the output is displayed in another form, its creating new form but i want to display it in my form only. Means i want it to be displayed on my form that i have created. Can u tell me how to do this???????
Plz help........
I tried to display in label or scroll pane but its giving me error cannot find the method i think its not compatible with this components. Can u plz help????????????

import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.category.*;
import org.jfree.chart.renderer.category.*;
public class BarChartExample{
public static void main(String arg[]){
JButton b=new JButton("Show Graph");
JFrame f=new JFrame();
f.setLayout(null);
b.setBounds(10,10,120,20);
final JLabel l=new JLabel();
l.setBounds(10,40,400,300);
f.add(l);
f.add(b);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(72, "Marks", "A");
dataset.setValue(75, "Marks", "B");
dataset.setValue(48, "Marks", "C");
dataset.setValue(98, "Marks", "D");
dataset.setValue(67, "Marks", "E");
JFreeChart chart = ChartFactory.createBarChart("BarChart using JFreeChart","Student", "Marks", dataset,
PlotOrientation.VERTICAL, false,true, false);
try{
File f=new File("C:/chart.jpg");
ChartUtilities.saveChartAsJPEG(f, chart, 400, 300);
ImageIcon icon=new ImageIcon(f.getPath());
l.setIcon(icon);
}
catch (IOException ex){
System.out.println("Problem in creating chart.");
}
}
});
f.setSize(500,450);
f.setVisible(true);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.