Hi all, I want to create graphs in java,graphs will be of type profit and loss percentage calculation.As per i have read there are many built in softwares that can be used in my program to draw ,but i am interested in drawing my own graphs by using java API's.can anyone advice me on to which package i must use to draw graph in java. Thanks in advance...
i would use Swing myself. Look at this part of the Java Tutorial. Apart from the fact that all the working is shown inside "main" methods, it is very helpful. Find the bits about JPanels and how to draw lines on them, which I think will be helpful.
Joined: May 08, 2007
Thanks for your reply, but one more doubt i have is once the value of X co-ordinat and y co-ordinate gets calculated then which GUI component or method can be used to plot the graph?
Joined: Oct 13, 2005
I would have thought the paintComponent() method of a JPanel is easiest to use. You find it is passed a Graphics object usually called g; you don't have to find the Graphics object, the JVM or something passes it for you. Try the g.drawLine() method using the Graphics object.
There isn't a lot I can find on a quick look at the Java Tutorial; look for JPanelhere, then sercah for "paintComponent", and Graphics is here. Beware; there is also a paintComponents() method.
Another warning: the y coordinates run from top to bottom.