Reputation: 582
I want to know if it is easy to draw a graph (circle and arrows to link each circles) using Java2D and Swing. And I want some tutorials or just small examples.
Upvotes: 0
Views: 5926
Reputation: 2973
Well it depends on what you're doing. If you're only doing things like drawing a line from a point to another point using the click of a mouse, then it is quite simple. For something like that, all you would need to do is implement the
public void drawComponent(Graphics g){
g.drawLine(/*xPosition of click*/,/*yPosition of click*/, null);
}
method inside your class, and then implement MouseListener for the mouse click. Just implement by doing
import ...
public class ClassName implements MouseListener
and then the mouse listener onto whatever component you're using such as a JFrame, JPanel, or anything such as those.
Hope that helps
Upvotes: 0
Reputation: 3352
Well, the API is quite easy to use, so it really depends on what you will be drawing...
See this website: http://docs.oracle.com/javase/tutorial/2d/
Upvotes: 1