Meaningless Drivel is fun!
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 REST with Spring (video course) this week in the Spring 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: 24195

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
subject: Graphs in swing
It's not a secret anymore!