Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Graphs in swing

 
Balan Allen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I draw a simple 2D graph using swing in a java application (without using an Applet)
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JFreeChart is a really good Library you can use for drawing Charts.
 
Let nothing stop you! Not even this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!