Home Tutorialhelp Comment Plot a XY graph using Java

 
 

Comment

Anuj Tiwari
Plot a XY graph using Java,
June 8, 2009 at 4:20 PM

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.math.*;
import java.util.*;

public class PlotXY extends JFrame
{
myView view = new myView();
Vector vr = new Vector();
int ho = 0;

public PlotXY()
{
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent ev)
{ dispose();
System.exit(0);}});


int [] a = {10, 20, 30, 40, 50};
int [] b = {15, 25, 35, 45, 55};


for (int i=0; i < 5; i++)
{
vr.add(new Point(a[i],b[i]));
}
setBounds(3,10,625,350);
view.setBounds(10,10,600,301);
getContentPane().add(view);
getContentPane().setLayout(null);
setVisible(true);
}
public class myView extends JPanel
{
BufferedImage I;
Graphics2D G;

public myView()
{
}
public void paint(Graphics g)
{
if (I == null)
{
I = new BufferedImage(getWidth(),getHeight(),BufferedImage.TYPE_INT_ARGB);
G = I.createGraphics();
}
G.setColor(new Color(213,199,181));
G.fillRect(0,0,getWidth(),getHeight());
G.setColor(Color.lightGray);
for (int y=0; y < 11; y++) G.fillRect(0,y*30,getWidth(),1);
G.setColor(Color.darkGray);
Point p1,p2;
p1 = (Point)vr.get(ho);
int x = 0;
for (int y=1; y < 5; y++)
{
p2 = (Point)vr.get(y+ho);
G.drawLine(x,p1.y+150,x+5,p2.y+150);
p1 = (Point)vr.get(y+ho);
x = x + 5;
}
g.drawImage(I,0,0,null);
}
}
public static void main (String[] args)
{
new PlotXY();
}
}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

plot a graph in Java
plot a graph in Java   I need to plot a graph in Java but the samples... need to plot them as I receive them. This requires calling repaint() again... and the final graph may be quite congested. So please guide me on this. Thanks 

Java Beginners

awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame 

Date Calendar

date and time in awt(java)
date and time in awt(java)  sir, do you have an example of date in awt java which can be view over a textfield.   Display time in JTextField import java.util.*; import javax.swing.*; import java.awt.event.*; public 

Java Beginners

java-awt - Java Beginners
java-awt  how to include picture stored on my machine to a java frame... "\" try using this...... img = Toolkit.getDefaultToolkit().getImage("C... information, http://www.roseindia.net/java/ Thanks 

General Information

What is AWT in java
What is AWT in java In this Example we will describe awt in java. The awt in java stands for Abstract Windowing Toolkit and is a package... In this example We have create frame in java AWT package. The frame in java works 

Java Beginners

Graphical calculator using AWT - Java Beginners
Graphical calculator using AWT  Hi Sir, Thanks for the reply.....and is it the same code we need implement on Graphical Calc using Swing? Here is the prg code... Calculator example"); this.setResizable(false); }//end constructor 

Java Interview Questions

awt - Java Interview Questions
awt  what is the difference between awt and swings  Hi friend, These are basically the main differences between awt and swing. 1.swing components sits on the top of AWT components and do the wiork. 2.AWT 

Java Beginners

displaying image in awt - Java Beginners
to display image using awt from here and when I execute the code I am getting... ActionListener{ JFrame fr = new JFrame ("Image loading program Using awt"); Label...://www.roseindia.net/java Thanks  You can use JAI (Java Advanced Imaging 

Java Beginners

Graphical calculator using AWT - Java Beginners
Graphical calculator using AWT  hi Sir, I need a source code for the following prgm...pls help me.. Implement a simple graphical calculator using...://www.roseindia.net/java 

Java Beginners

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 

JSP-Tutorials

What is AWT in java
What is AWT in java      .../api/java/awt/package-summary.html... available with JDK. AWT stands for Abstract Windowing Toolkit. It contains all classes 

Java Beginners

plotting a graph - Java Beginners
plotting a graph  pls help me out regarding plotting a graph. I have done that through LiveGraph API. but now i required the graph to be displayed on the gui- window. and whatever inputs i will pass it must change the graph 

Applet Questions

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...Applet Graph  hai, iam new to java plz help me.. 1..i have a table 

Java3D Questions

radar graph in java
radar graph in java  Hi All I am developing a java application... { public DefaultCategoryDataset dataset; public SpiderWebPlot plot...); SpiderWebPlot plot = new SpiderWebPlot(dataset 

General

Java AWT Package Example
Java AWT Package Example      ... to handle different key events on the Java Awt component by using the event... This is a simple program of java awt package which constructs a look like a form by using 

Java Beginners

awt
Java AWT Applet example  how to display data using JDBC in awt/applet 

Java Beginners

java-graph help - Java Beginners
java-graph help  sir/madam I wanted to design a shortest path Algorithm. i wanted to show the shortest path in graphical format in the way it looks... to print the variable value in the diagram. i know to write constant value by using 

Java Beginners

Graph in JAVA SWING
Graph in JAVA SWING  Hi, How to draw a simple GRAPH in JAVA SWING ?  ..., Please visit the following link: Bar Graph in Java Swing Thanks 

Swing AWT

Drawing Graphs - Swing AWT
Drawing Graphs  hi i am doing a small project in java swings . there is a database table having two columns A,B i want to plot a graph to that values in database the graph must be interactive graph 

Java Beginners

Multi line graph - Java Beginners
Multi line graph  Hi, I want a multi line graph on a single chart using jfree in java.... Can you please let me know the code... thanks in advance  Hi Friend, Loginto the below mentioned URl & download the file 

General

java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform.... The implementation of the user interface elements provided by the AWT is done using... is used by each AWT component to display itself on the screen. For example 

Java Beginners

make chart or graph from database - Java Beginners
I am sending a link where u find many example related to chart and graph...make chart or graph from database  d, I want to ask about how to make a chart or graph. First i have Table name= "customer" and field =(cust_id 

Swing AWT

awt - Swing AWT
market chart this code made using "AWT" . in this chart one textbox when user..., For solving the problem visit to : http://www.roseindia.net/java/example/java/awt/ Thanks 

Java Beginners

Create Bar Graph from reading excel sheet in Java
Create Bar Graph from reading excel sheet in Java  I'm New to Java and I have to create a java program where I have to read data from multiple excel... and plot a bar graph between browser and test case pass/fail based on the data 

Swing AWT

java swings - Swing AWT
write the code for bar charts using java swings.  Hi friend, I am.... http://www.roseindia.net/java/example/java/swing/draw-simple-bar...java swings  I am doing a project for my company. I need a to show 

Blog

AWT basics
, graphics, and user-interface for the desktop application using Java technology. Now a day?s developers are using Swing components instead of AWT to develop... AWT documentation AWT example AWT manual AWT tutorial 

Swing AWT

java-swings - Swing AWT
java-swings  How to move JLabel using Mouse? Here the problem is i...://www.roseindia.net/java/example/java/swing/ Thanks. Amardeep... at runtime by moving labels using mouse. Plz tell me the correct way to solve 

Java Interview Questions

Java AWT
Java AWT  What interface is extended by AWT event listeners 

Java Beginners

Ask make graph from i report and view to java Language Programming
Ask make graph from i report and view to java Language Programming  Dear sir, Please help me, i want to make a graph from mysql to i report and view to java. Please help me, give me example source code please. thank you 

Java Interview Questions

Java AWT
Java AWT  What is meant by controls and what are different types of controls in AWT 

Java-Tutorials

Create a Container in Java awt
Create a Container in Java awt     ... on the frame has been specified south of the frame by using BorderLayout.SOUTH since the position of the text area has been specified the center of the frame using 

Applet Questions

AWT Tutorials
AWT Tutorials  How can i create multiple labels using AWT????   Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import 

JDBC Questions

java + excel data +graph - JDBC
java + excel data +graph  i am doin' a project in which i need... a graph with the facility of drawing a trendline(in the graph)...also i need to be able to select points in the graph and draw the graph again between those 

Swing AWT

JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java 

Swing AWT

JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java 

Swing AWT

JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java 

Applet Questions

Applet program for drawing picture and graph - Applet
the program(code) of drawing picture and graph in Applet.  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java/applet/ http://www.roseindia.net/tutorial/java/swing/createHumanFace.html Hope 

Chart and Graphs

Combined Category Plot Example using JFreeChart
Combined Category Plot Example using JFreeChart       This Example shows you how to create a Combined Category Plot chart using JFreeChart. Code for the chart shows 

Java Beginners

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 

Swing AWT

Java Dialogs - Swing AWT
/springlayout.html http://www.roseindia.net/java/example/java/awt/borderlayout-example... visit the following links: http://www.roseindia.net/java/example/java/swing...Java Dialogs  a) I wish to design a frame whose layout mimics 

Swing AWT

java - Swing AWT
information, http://www.roseindia.net/java/example/java/awt/ Thanks...java  i want a program that accepts string from user in textfield1 and prints same string in textfield2 in awt   hi, import java.awt. 

Swing AWT

Line Drawing - Swing AWT
Line Drawing  How to Draw Line using Java Swings in Graph chart...) { System.out.println("Line draw example using java Swing"); JFrame frame = new... using java Swing import javax.swing.*; import java.awt.Color; import 

Swing AWT

Java - Swing AWT
Java    Hi friend,read for more information,http://www.roseindia.net/java/example/java/swing 

Swing AWT

java - Swing AWT
java  How can my java program run a non-java application. Will it be possible to invoke a gui application using java 

Swing AWT

java - Swing AWT
java   Write Snake Game using Swings 

Swing AWT

Java Swings problem - Swing AWT
Java Swings problem  Sir, I am facing a problem in JSplitPane. I want... pane. For example, if the split pane is of dimension (0,0,100, 400), then divider... of using BasicSplitPaneUI, BasicSplitPaneDivider etc etc but no solution. Please give 

Applet Questions

JAVA AWT BASE PROJECT
JAVA AWT BASE PROJECT  suggest meaningful java AWT-base project 

Java Beginners

java awt calender
java awt calender  java awt code for calender to include beside a textfield 

Swing AWT

java - Swing AWT
java  how to use JTray in java give the answer with demonstration or example please 

Swing AWT

Java Code - Swing AWT
Java Code  Write a Program using Swings to Display JFileChooser that Display the Naem of Selected File and Also opens that File 

Swing AWT

java - Swing AWT
What is Java Swing AWT  What is Java Swing AWT 

Swing AWT

Java Program - Swing AWT
Java Program  A program to create a simple game using swings.  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java/swing/guessNumber.html Thanks 

Java Tips and Examples

Java AWT Package Example
 

Swing AWT

java - Swing AWT
java  i need to set the popup calender button in table column&also set the date in the same table column using core java-swing 

Swing AWT

Java Code - Swing AWT
Java Code  How to Make an application by using Swings JMenuBar and other components for drawing various categories of Charts(Line,Bar etc 

Swing AWT

java - Swing AWT
Java Implementing Swing with Servlet  How can i implement the swing with servlet in Java? Can anyone give an Example??   Implementing Swing with Servlet Example and source Code Servlet SwingToServlet 

Java Interview Questions

Java AWT
Java AWT  What is the relationship between the Canvas class and the Graphics class 

Swing AWT

java swing - Swing AWT
: http://www.roseindia.net/java/example/java/swing/ Thanks...java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image. 

Java Interview Questions

Java AWT
Java AWT  How can the Checkbox class be used to create a radio button 

Swing AWT

java - Swing AWT
java  how can i add items to combobox at runtime from jdbc   Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/AddRemoveItemFromCombo.shtml Thanks  Hi Friend 

Swing AWT

compareing images using java - Swing AWT
compareing images using java  hi can u please give me the code in java to compare imges..i have the program to get the pixel values using pixel... with another image,i.e,program to compare two images using the pixel values.. thank 

Swing AWT

AWT-swings tutorial - Swing AWT
://www.roseindia.net/java/example/java/swing/ http://www.roseindia.net/java/example/java...AWT-swings tutorial  hello sir, i am learnings swings and applets.. i want some tutorials and some examples related to swings.. thank you sir 

Java Interview Questions

Java AWT event hierarchy
Java AWT event hierarchy  What class is the top of the AWT event hierarchy?  The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy 

Java Beginners

jfree - Java Beginners
jfree  how use the "import jfree" on jdk1.5.0_6,, or how to plot data in xy line on jdk1.5.0_6 

Swing AWT

Java - Swing AWT
. http://www.roseindia.net/java/example/java/swing...("Paint example frame") ; getContentPane().add(new JPaintPanel 

Swing AWT

java - Swing AWT
java   Hello Sir/Mam, I am doing my java mini... it either on panel or frame.But in my project,i have to image using JFileChooser... for upload image in JAVA SWING....  Hi Friend, Try the following code 

Swing AWT

Java - Swing AWT
Java  program to read,add,update,delete the database using swing and servlet 

Swing AWT

Java Code - Swing AWT
Java Code  How to Display a Save Dialog Box using JFileChooser and Save the loaded Image from Panel in any Location.  Hi Friend, Try the following code: import java.io.*; import java.awt.*; import java.util. 

Swing AWT

java - Swing AWT
java  iam getting the xml result then i'll save my result in folder using jfilechooser in swings.give me any examples 

Swing AWT

JAVA - Swing AWT
JAVA  Sir how can i design flow chart and Synopsis for random password generation by using swing in java .  Hi Friend, Try the following code: import java.io.*; import java.util.*; import java.awt.*; import 

Swing AWT

java - Swing AWT
java  hi can u say how to create a database for images in oracle and store and retrive images using histogram of that image plz help me its too urgent 

Swing AWT

Java - Swing AWT
Java  program to read,add,update,delete the database using swing and servlet  Hello Just Refer Don't Copy the content of this URL http://java2s.com/ Thanks Rajanikant  Hi friend, To solve 

Swing AWT

java - Swing AWT
java  Hi, I override the mouseClicked interface in my code and get the X and Y coordinates of the event using e.getX() and e.getY(). Is there a way to obtain the text at that location?  Hi Friend, Please clarify 

Swing AWT

java - Swing AWT
java  hello..can u please send me the coding for the body of yahoo messenger only body and event handling on window closing so that it should ask on exit that "are you sure you want to exit?"..using GridBagLayout.. urgently pls 

Swing AWT

query - Swing AWT
java swing awt thread query  Hi, I am just looking for a simple example of Java Swing 

Swing AWT

Java Program - Swing AWT
Java Program  Write a Program that display JFileChooser that open a JPG Image and After Loading it Saves that Image using JFileChooser  Hi Friend, Try the following code: import java.io.*; import java.sql. 

Swing AWT

awt list item* - Swing AWT
information. http://www.roseindia.net/java/example/java/awt/ Thanks...awt list item*  how do i make an item inside my listitem...); choice.add("Java "); choice.add("Jsp"); choice.add("Servlets 

Java Beginners

how to implements jdbc connections using awt?
how to implements jdbc connections using awt?   My name is Aditya... example awt with jdbc.   We are proving you a simple application of Login and Registration using java swing. 1)LoginDemo.java: import javax.swing. 

Java Beginners

java awt components - Java Beginners
java awt components  how to make the the button being active at a time..? ie two or more buttons gets activated by click at a time 

Swing AWT

AWT code for popUpmenu - Swing AWT
for more information. http://www.roseindia.net/java/example/java/awt/pop...AWT code for popUpmenu  Respected Sir/Madam, I am writing a program in JAVA/AWT.My requirement is, a Form consists of a "TextBox" and a "Button 

Swing AWT

Look and Feel - Swing AWT
: http://www.roseindia.net/java/example/java/swing/GettingAndSettingLAF.shtml http://www.roseindia.net/java/example/java/swing/DefaultLookAndFeel.shtml Hope...Look and Feel  i m using netbeans for creating a swing GUI 

Swing AWT

swings - Swing AWT
swings  how to develope desktop applications using swing  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/ Here you will get lot of swing applications 

JDBC Questions

awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt 

Swing AWT

Java Swings-awt - Swing AWT
Java Swings-awt  Hi, Thanks for posting the Answer... I need to design a tool Bar which looks like a Formating toolbar in MS-Office Winword(Standard & Formating) tool Bar. Please help me... Thanks in Advance 

Java Beginners

Awt programming with java
Awt programming with java  Write a java program, which provides a text area with horizontal and vertical scrollbar.Type some lines in the text area and use scrollbars to move the text within the text area.Read a word in a text 

Swing AWT

provide code - Swing AWT
GAME.....using swings,awt concepts   Hi friend, import java.awt....); } } ------------------------------------- visit for more information. http://www.roseindia.net/java/example/java/swing/ Thanks 

Swing AWT

SWINGS - Swing AWT
more information,Examples and Tutorials on Swing,AWT visit to : http://www.roseindia.net/java/example/java/awt/ http://www.roseindia.net/java/example/java 

Swing AWT

SWT_AWT bridge ,jtextfield edit problem - Swing AWT
SWT_AWT bridge ,jtextfield edit problem  Hi All, I am using SWT_AWT...(display); shell.setText("Using Swing and AWT"); shell.setSize(350... visit to : http://www.roseindia.net/java/example/java/swing/ Thanks 

Swing AWT

scrolling a drawing..... - Swing AWT
information. http://www.roseindia.net/java/example/java/swing/use-canvas...scrolling a drawing.....  I am using a canvas along with other components like JTable over a frame the drawing which i am going to show over canvas 

Swing AWT

Java Compiler error - Swing AWT
Java Compiler error  Hi, I try to add quartz Lib in my HelloQuartz... can add Jar File in Java Build Path Library. i get this message : " No entries... and commons-collections.jar in JAVA BUILD PATH/Libraries/, By Clicking ADD External JAR 

Swing AWT

Java logical error - Swing AWT
Java logical error  Subject:Buttons not displaying over image Dear Sir/Madam, I am making a login page using java 1.6 Swings. I have want to apply picture in the backgoud of the frame and want to place buttons 

Java Beginners

java
java  how we can create the purches order by using the java awt 

Java Beginners

java
java  how we can create purches order format by using the java awt 

Java Beginners

java
java  how we can create purches order format by using the java awt 

JDBC Questions

java
java  how we can create purches order format by using the java awt 

Java-Tutorials

Event handling in Java AWT
Event handling in Java AWT     ... events in java awt. Here, this is done through the java.awt.*; package of java. Events are the integral part of the java platform. You can see the concepts 

Java Beginners

reading data from excel file and plotting graph
excel to plot on an axis in graph... using NetBeans in which i have to take input an excel file and then using the data in excel file, i have to plot graphs based on CELL ID selected. please help 

Swing AWT

Java swing in NetBeans - Swing AWT
Java swing in NetBeans   thanks a lot sir for everything you answered for my last questions now sir i just have another 3 questions that is Q 1. i will specify a swing code for JTable using NETBEANS so would you tell me 

Swing AWT

How to put the logo in login form using swings/awt?
How to put the logo in login form using swings/awt?  Hi, How to put the logo in login form using swings/awt? I write the login form is working but i want to put the logo in login form plz help   Here is an example 

Swing AWT

virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  sir thanks a lot for ur reply for my last question, can u please send me the entire project code of virtual on screen keyboard.i did but im not sure as it was right 

Advertisements Advertisements
 

 

 

DMCA.com