Draw a simple line graph in Swing

1.8k Views Asked by At

How can i draw a line graph in Java Swing. I'm making a program in which when user clicks on a jframe it will record its coordinate and when it click on a button named Draw Graph, it generates a line graph using the points. So, How can i draw a line graph in Swing

3

There are 3 best solutions below

4
On BEST ANSWER

You can use JFreeChart to plot different kinds of graphs.

0
On

You could use http://gef.tigris.org/ gef library in order to represent your graphs.

3
On

The IMHO easiest way is extending a JComponent and overwriting the related paintComponent(Graphics) method.

[EDIT] Inserted correct method name.