I want to add some objects into an Composite
object. Objects can have different shapes (rectangle, circle, ellipse or even weird shape (represented by a polygon). So I defined classes like this:
public class Circle extends Canvas {
}
public class Rectangle extends Canvas {
}
...
I know how to draw in a Canvas
to get the shape I want, but I also expected that the popup menu appears at each canvas only if the users click mouse inside the canvas area, so if I use these code in a composite class:
Menu aSampleMenu = new Menu(this);
Circle circle = new Circle(parent, style);
circle.setMenu(aSampleMenu);
the menu will appear if the user click right mouse button anywhere inside the canvas, even outside the shape area. How can I fix this problem?