Home Answers Viewqa Java-Beginners To display the bar graph

 
 


Prajakta S
To display the bar graph
1 Answer(s)      a year and 5 months ago
Posted in : Java Beginners

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 Pages:
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
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
Bar graph
Bar graph  How to include a bar chart in iPhone sdk
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
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
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
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 ?  
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
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
PHP GD line graph
,'Line Graph by: Roseindia Technologies',$red); imagepng($im); ?> After
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
graph generation using jfreechart and retrieving values from the database
database using prepared statement and then display the bar graph using jfreechart API .This whole retrieval and display of chart is to be done in a servlet...graph generation using jfreechart and retrieving values from the database 
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
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
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
Representing Graph using adjacency list & perform DFS & BFS
Description: This tutorial demonstrate how to create a graph using adjacency list and perform DFS and BFS. Different kind of graph are listed below: Directed Graph: A directed graph is one in which edges connect nodes in only one
Progress Bar in Java
; On Execution of the Program code ,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
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
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
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
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
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
reading data from excel file and plotting graph
, generated a bar chart. The given code uses Apache POI api and Jfreechart api. import... excel to plot on an axis in 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
Swings Menu Bar - Java Beginners
Swings Menu Bar  Hello, I created a menu bar using Java Swings... n New Record, Edit Record etc are the menu items. Now, I want to display... bar... How to do this..?? or atleast what to use to get this..??  Hi
Bar Chart
Bar Chart       This section illustrates you how to create bar chart using html in jsp. To draw a bar chart, we have used html tags. In this, firstly
Create Expand Bar in SWT
Create Expand Bar in SWT       This section illustrates you how to create an Expand Bar. SWT provides an application of creating a Expand Bar using the classes ExpandBar
Progress Bar in Java Swing
Progress Bar in Java Swing       In this section, you can learn how to handle progress bar in java swing. This section shows you how the progress bar starts and stops
3D Bar Chart
3D Bar Chart       In this section we are providing you an example to create a 3D Bar Chart. Description of Program  For creating a 3D Bar chart we use the object
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
Progress Bar in Java
; On Execution of the Program code ,The Progress Bar display as follows... Progress Bar in Java       Progress Bar is a component used to show the status of the application
Removing the title bar of the Frame in Java
how to display the frame or window without title bar in java. This type... Removing the title bar of the Frame in Java  ... to hide the title bar of the frame or window. The frame is initially by default
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)
i have to display a graph between a student semester-marks .(semesters on x...how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)  I have created a servlet.In this,i
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
Menu Bar in Java
Menu Bar in Java       A Menu Bar is a set of option that allow the user to choose from...; a user can choose in a menu bar. In this Tutorial we want to describe you how
jfreechart display from access database data.
to retrieve the data from the access database using prepared statement and then display the bar graph using jfreechart API .This whole retrieval and display of chart...jfreechart display from access database data.  I have made a database
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
Menu Bar in Java
Menu Bar in Java       A Menu Bar is a set of option that allow the user to choose from any one... choose in a menu bar. In this Tutorial we want to describe you how to create a Menu
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
Search bar application
Search bar application In this tutorial, will be creating a Search screen, which have a table view with a search bar. Table should display all the data... matching with the search string UISearchBar *sBar;  //search bar @property
Bar Chart in Java
to draw simple bar chart in Java. A bar chart (bar graph) is a way of comparing two... Bar Chart in Java      ... or vertically oriented. We are providing you an example which shows the Bar
Create Menu Bar in SWT
Create Menu Bar in SWT       This section illustrates you how to create a menu bar. In SWT... to create a menu bar. The method setMenu() sets the pull down menu. The SWT.SEPERATOR
Stacked Bar Chart Example using JFreeChart
Stacked Bar Chart Example using JFreeChart... a Stacked bar chart using JFreeChart. Bar chart will represent scores of two team... for display frame on the screen. createCategoryDataset(): This method is used
JFreeChart- Display coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
Stacked Bar Chart using JFreeChart
Stacked Bar Chart using JFreeChart   ... bar chart using JFreeChart. In the code given below we have extended class... is used for display frame on the screen. addValue(): This method is used for add
Stacked 3d Bar Chart Example using JFreeChart
Stacked 3d Bar Chart Example using JFreeChart... a Stacked 3d bar chart using JFreeChart. Bar chart will represent the score...(): This method is used for display frame on the screen. createCategoryDataset
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

Ask Questions?

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.