• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

X Y Graph

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic