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
posted
0
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