File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Graphs in swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Graphs in swing" Watch "Graphs in swing" New topic

Graphs in swing

Balan Allen

Joined: Sep 14, 2003
Posts: 2
How can I draw a simple 2D graph using swing in a java application (without using an Applet)
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

Hi Balan,
Welcome to Java Ranch!
Yes, you sure can. If it's simple, you might want to do it yourself, from scratch, just using the 2D API calls (methods like drawLine() in the java.awt.Graphics2D class.) There are lots of interesting examples in the JDK; see the demos/jfc/Java2D subdirectory of your JDK directory.
If you want to make more complex graphs, then do a Google search on "Java graph library" -- you'll find plenty.

[Jess in Action][AskingGoodQuestions]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

JFreeChart is a really good Library you can use for drawing Charts.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: Graphs in swing