wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes X Y Graph Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "X Y Graph " Watch "X Y Graph " New topic
Author

X Y Graph

Bethany Lunah
Greenhorn

Joined: Nov 27, 2002
Posts: 1
Hi Everyone,
I'm new to Java Programming and wondered if anyone out there could give me some advice for finding an example of making a graph with Java? I've got to give two text boxes for x & y input, then register those two numbers using a JButton then have the program graph that point on an x, y line graph using a JButton also! I've got some of the basics of this but I'm still trying to see how it all comes together
Thank you!
Ashish Hareet
Ranch Hand

Joined: Jul 14, 2001
Posts: 375
Hi,
I've never done this before but gave it a shot & here's what I came up with -
1. Extend JPanel
2. setPreferredSize() to whatever & not setSize()
3. override paintComponent making sure that you first call the super class method
4. Plot your points in the paintComponent method - remember that (0,0) is on the upper left hand side & you'll have to transform your co-ordinate space so that (0,0) is on the lower left hand side
5. Put an instance of your JPanel subclass in a JScrollPane & add it to some container
I don't know if this is right way to do it but hope it'll get you started. Also try a google search on JFreeChart & you won't have to bother with this.
Ashish Hareet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: X Y Graph