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 Painting graph and charts with Java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Painting graph and charts with Java." Watch "Painting graph and charts with Java." New topic

Painting graph and charts with Java.

Olena Golub
Ranch Hand

Joined: Jan 17, 2005
Posts: 113
Hello Everyone,

I read a lot of information that the Swing and AWT components should not be used together. I need to implement in my Java application that is based on SWING the possibility to draw graph and charts. I found that the Java 2D can be used for this. But it�s based on JDK 1.3 and based on the AWT components. And my application work with 1.4.
And my question is, are there are some Java libraries (from SUN), that I can use for drawing 2D graph and charts? Or can I use Java 2D with my Swing components together?

Thanks a lot for your help!

SCJP 1.4<br />SCJD 1.4 (in progress)
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

You can certainly combine Swing and AWT components in the same application, but you need to know what you're doing. The main issue is that a Swing component can't be "in front of" most AWT components; so, for example lightweight Swing menus and pop-ups won't be drawn properly on top of a Panel full of Buttons and Choice objects (as opposed to a JPanel filled with JButtons and JComboBoxes, the Swing eqivalent.)

Swing itself is drawn with Java2D. If you have a Java2D-based graph library, it's quite likely that it can be used to draw on a JPanel with little or no modification, anyway.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Painting graph and charts with Java.
It's not a secret anymore!