Search code examples
javaeventsgraphicsjava-2d

How to generate events from graphics generated by Java2D


I have made an Ellipse with the help of java.awt.geom.Ellipse2D

Now, I want that whenever user clicks on that ellipse, an event is generated so that I can listen to that event and peform subsequent tasks based on the ellipse which generated that event.


Solution

  • Here is a simple example of an object drawing program that demonstrates click, drag and multiple selection. Also consider JGraph, which is a much more advanced library for graph visualization.