To display the bar graph

To display the bar graph

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????????????

View Answers

December 29, 2011 at 12:43 PM

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);
  }
}









Related Tutorials/Questions & Answers:
To display the bar graph
To display the bar graph  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... but i want to display it in my form only. Means i want it to be displayed on my
Bar graph
Bar graph  How to include a bar chart in iPhone sdk
Advertisements
Create Bar graph
Create Bar graph  hi............. In my project i want to create a BAR GRAPH to display the result. I HAVE certain values that want to show in graph form. Can u help me plzzzzzzz i require a very simple code in java swings were
datewise/monthwise bar graph
datewise/monthwise bar graph  How to make a datewise/monthwise bar graph using the values from the ms access database? please help its urgent
Read Excel file and generate bar graph
Read Excel file and generate bar graph In this tutorial, you will learn how to read an excel file and generate bar graph. Here is an example that reads... the data of excel file, we have generated a bar chart. The given code uses Apache
Create Bar Graph from reading excel sheet in Java
Create Bar Graph from reading excel sheet in Java  I'm New to Java... and plot a bar graph between browser and test case pass/fail based on the data in the different excel sheets (data can change and based on that graph should also get
Graph
Graph  What is the code to generate the following graphs? 1.Simple Bar diagram 2.Sub-divided Bar diagram 3.Pie chart Please Help!!!!   Please visit the following link: Java charts and graphs
php gd bar graph
Fetching data from excel file on other website and display in interactive graph form
Fetching data from excel file on other website and display in interactive graph form  Hello, I am making a website using HTML and CSS, I am done with the layout, I have to generate ineractive graphs like stock market's, Can you
Bar Chart
Bar Chart  hi...... Thanks 4 ur help for the bar graph creation i have got what i wanted. But now want to ask that in that bar graph i want multiple bar on one value means I want to create a graph where on my x-axis i have
PHP GD line graph
($im,3,10,$height-20,'Line Graph by: Roseindia Technologies',$red);ADS_TO_REPLACE_12
Graph in JAVA SWING
, Please visit the following link: Bar Graph in Java Swing Thanks...Graph in JAVA SWING  Hi, How to draw a simple GRAPH in JAVA SWING ?  
Create Progress Bar in SWT
Create Progress Bar in SWT   ... Bar. SWT allows to create a Progress bar by providing the class ProgressBar of package org.eclipse.swt.widgets. With the use of this class, you can display
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Stacked Bar Chart
Stacked Bar Chart  How to display a stacked bar chart using java from the values stored in the ms access database?Plzz help..its urgent
about graph - Applet
about graph  How to draw a graph in applet and that should be display in web browser? How to make a running applet in our browser? for example ticker
bar chart
bar chart  how to create a bar chart from values of the database and the string value should be the entities of the database??plzz help..needed badly
to show graph
to show graph  by clicking on submit button how to show the graph by fetching data in mysql?   Please visit the following link: JSP graph by fetching data in mysql
Version of commons-graph>commons-graph dependency
List of Version of commons-graph>commons-graph dependency
line graph
line graph  I have developed an application and in that i have to compare 2 reports using line graph from the data taken from ms access database?please help
How to make a line graph in Matplotlib?
Matplotlib Examples - How to make a line graph in Matplotlib? In this tutorial we are going to create simple line graph in Matplotlib library. You can run... including generate plots, histograms, power spectra, bar charts, errorcharts
How to make a line graph in Matplotlib?
Matplotlib Examples - How to make a line graph in Matplotlib? In this tutorial we are going to create simple line graph in Matplotlib library. You can run... including generate plots, histograms, power spectra, bar charts, errorcharts
Applet Graph
columns-names by using check box and click on graph button, 3..then i have to get a graph between those columns in a applet plz send me the code thank u
Progress Bar
Progress Bar  Hi friend, I'm interested in knowing how to progress bar in oracle forms 9i for the trigger when-button-pressed.Thankyou. Thanks and Regards, M.SHANKAR
progress bar
progress bar  Hi guys, I'm doing a file upload in spring MVC technology. For file upload i did validation in client side.While uploading how to use an ajax function to show the progress bar
JFreechart Stacked Bar Chart
. In the following example, each bar of the stacked bar graph is divided into two...JFreechart Stacked Bar Chart JFreechart provides a way to create various charts by just using the methods of different classes. You are well aware of bar
Autoupdating graph
Autoupdating graph  Hey Anyone who might help me making a XY graph, that autoupdates lets say every 5th minute. All the datasets comes from an mySQL database, and the dataset in the database, comes from a txt file and are being
JFreeChart- Display coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
Bar chart with J table
tell me how can I make a bar graph that will display the data from my table.I tried using the code from your page (http://www.roseindia.net/chartgraphs/bar...Bar chart with J table  Hi I'm new in Java and I have a application
How to create bar chart using database values
How to create bar chart using database values  How to create bar chart using database values i.e excellent,good,average fields using jsp?It is like... in a graph format
hide the url in address bar
hide the url in address bar  how i can hide url in address bar????? i... displayed in the address bar? url not visible to endusers please tell me any... username and password....so i dont want to like that?i want to display the answer
menu bar in javascript - JSP-Servlet
menu bar in javascript  sir i need to display menu bar with some background color.in each menu,there are some values to display as menu.again if i select each value,again a sub menu to display.plz send me some code. menubar
ModuleNotFoundError: No module named 'graph'
ModuleNotFoundError: No module named 'graph'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'graph' How to remove the ModuleNotFoundError: No module named 'graph'
ModuleNotFoundError: No module named 'graph'
ModuleNotFoundError: No module named 'graph'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'graph' How to remove the ModuleNotFoundError: No module named 'graph'
Progress Bar in Java
,The Progress Bar display as follows... Progress Bar in Java       Progress Bar is a component used to show the status of the application
Bar chart implementation in PHP
Bar chart implementation in PHP  How to implements reports in bar graphs by using PHP
ModuleNotFoundError: No module named 'bar'
ModuleNotFoundError: No module named 'bar'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'bar' How to remove the ModuleNotFoundError: No module named 'bar' error
Version of com.daedafusion>graph dependency
List of Version of com.daedafusion>graph dependency
Removing the Title Bar of a JFrame
Removing the Title Bar of a JFrame  How to remove the Title Bar of a JFrame in Swing Application?   Please check the tutorial Removing the Title Bar of a Frame for the source code and example description. Thanks
What is Graph Database
What is Graph Database  Hi, What is Graph Database? Thanks   Graph Database? Graph Database is special kind of database which is used to store graph data formats. It provides API for saving the graph data into Graph
What is Graph Database
What is Graph Database  Hi, What is Graph Database? Thanks   Graph Database? Graph Database is special kind of database which is used to store graph data formats. It provides API for saving the graph data into Graph
JFree 3D Bar Chart not displaying in JSP - Java3D
JFree 3D Bar Chart not displaying in JSP  Hi I am trying to run JFree 3D bar chart written in your site under link: http://www.roseindia.net... and graph is not showing up. Please help. Sidhartha   Hi Friend
Bar charts and jsp
Bar charts and jsp  Hi, How to generate Dynamic Bar Chart Images using jsp with placing any image location in weebroots? Thanks in advance
hybrid graph (jfree chart) - Swing AWT
hybrid graph (jfree chart)  hello i have a problem related to jfree chart.I want to display hybrid graph (Stacked Area and Line ).combination.... Thanks.   Hi, Plz what the requirement of hybrid graph
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart
custom navigation bar in iphone
custom navigation bar in iphone  How can i create a custom navigation bar in iPhone application? I wanted to add UIBarButton items as well as Search bar on the UINavigation controller ... please tell me if i need to create
UINavigationController hide navigation bar
UINavigationController hide navigation bar  HI, How to hide the navigation bar of UINavigationController? I have to hide navigation bar... code for hiding UINavigationController's navigation bar
Artifacts of commons-graph
List of Artifacts of commons-graph maven depenency
Bar Chart
Bar Chart       In this section we are providing you an example to create a Bar Chart. Description of Program  For creating a Bar chart we use the object
plot a graph in Java
plot a graph in Java   I need to plot a graph in Java but the samples are not known in advance. The samples keep on coming through callback and I... and the final graph may be quite congested. So please guide me on this. Thanks

Ads