0

I have 2 classes, A and B. A is a subclass of Program (i.e. acm.program.*) and B is a subclass of GCanvas(i.e. acm.graphics.*).

In Class A I have an init method which initiates and adds class B.

In Class B I have 2 things I want to achieve: I want to respond to changes in the window size and mouse clicks. I can achieve the window size changes by adding component listeners. I cannot achieve the mouse clicking events.

Now, I know how I would do it in a situation where I didn't care about responding to window re-sizing. I would have 1 class, extend GraphicsProgram, and add mouselisteners and not have any problem.

What is your recommendation? How do I have these two events handlers exist concurrently within a single GCanvas? Thank you.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
Steven
  • 29
  • 1
  • 1
  • 6

1 Answers1

0

As a GCanvas is, from the documentation, an awt Component, you can always call this class addMouseListener() or addMouseMotionListener() method and do what you want with mouse events.

Riduidel
  • 22,052
  • 14
  • 85
  • 185
  • If you think this answer is the correct one **don't** say thank you, but rather accept it using the check at left side (just below the up/down arrows). – Riduidel Mar 16 '11 at 09:30