Home arrow static arrow Java Programming [Archive] - Event and listener in not Jcomponent class
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Event and listener in not Jcomponent class
This topic has 1 reply on 1 page.

Posts:2
Registered: 10/8/01
Event and listener in not Jcomponent class  
Jun 21, 2004 7:57 PM



 
Hello everybody,

I'm currently working on graphics application to draw charts. I have one
class Chart who extends JComponent and differents objects in Chart class
(sub_chart, tool_bar etc. who do not extend JComponent for optimization
reason).

My Chart class listens for mouse event, and send these events to each of the
class it contains, depending the coordinate where the mouse is clicked,
dragged... that permits to the other classes to manage their events.

My implementation is :
class Chart extends JComponent
with a inner class
private class MouseHandler extends MouseAdapter implements
MouseMotionListener
for mouse events.

then, I have :
class Plot implements PlotDraggedListener

When the Chart receive a MouseEvent inside the bounds of the Plot (by
calling plot.isInPlotBounds(e.getPoint())) the Chart sends a
PlotDraggedEvent to Plot who make a action.

Does it seems a good way to do that ?
Is there another solution ?

Thanks in advance for your responses.
 

Posts:14,142
Registered: 99-04-02
Re: Event and listener in not Jcomponent class  
Jun 23, 2004 11:46 AM (reply 1 of 1)



 
if it works, go with it
 
This topic has 1 reply on 1 page.