1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 import sun.awt.*;
25 import com.sun.star.awt.*;
26 import com.sun.star.lang.*;
27 import java.util.*;
28 import javax.swing.*;
29 
30 public class WindowAdapter
31 {
32     private java.awt.Frame  maFrame;
33     private LinkedList      maEventListeners = new LinkedList();
34     private LinkedList      maWindowListeners = new LinkedList();
35     private LinkedList      maFocusListeners = new LinkedList();
36     private LinkedList      maKeyListeners = new LinkedList();
37     private LinkedList      maMouseListeners = new LinkedList();
38     private LinkedList      maMouseMotionListeners = new LinkedList();
39     private LinkedList      maPaintListeners = new LinkedList();
40     private boolean         mbShift = false, mbMod1 = false, mbMod2 = false;
41 
42     // -----------------
43     // - WindowAdapter -
44     // -----------------
45 
WindowAdapter( int windowHandle )46     public WindowAdapter( int windowHandle )
47     {
48         maFrame = SystemWindowAdapter.createFrame( windowHandle );
49     }
50 
51     //----------------------------------------------------------------------------------
52 
getJavaFrame()53     public java.awt.Frame getJavaFrame()
54     {
55         return maFrame;
56     }
57 
58     //----------------------------------------------------------------------------------
59 
implGetUNOKeyCode( int nJavaKeyCode )60     private short implGetUNOKeyCode( int nJavaKeyCode )
61     {
62         short nRet = 0;
63 
64         switch( nJavaKeyCode )
65         {
66             case( java.awt.event.KeyEvent.VK_NUMPAD0 ):
67             case( java.awt.event.KeyEvent.VK_0 ):       nRet = com.sun.star.awt.Key.NUM0; break;
68             case( java.awt.event.KeyEvent.VK_NUMPAD1 ):
69             case( java.awt.event.KeyEvent.VK_1 ):       nRet = com.sun.star.awt.Key.NUM1; break;
70             case( java.awt.event.KeyEvent.VK_NUMPAD2 ):
71             case( java.awt.event.KeyEvent.VK_2 ):       nRet = com.sun.star.awt.Key.NUM2; break;
72             case( java.awt.event.KeyEvent.VK_NUMPAD3 ):
73             case( java.awt.event.KeyEvent.VK_3 ):       nRet = com.sun.star.awt.Key.NUM3; break;
74             case( java.awt.event.KeyEvent.VK_NUMPAD4 ):
75             case( java.awt.event.KeyEvent.VK_4 ):       nRet = com.sun.star.awt.Key.NUM4; break;
76             case( java.awt.event.KeyEvent.VK_NUMPAD5 ):
77             case( java.awt.event.KeyEvent.VK_5 ):       nRet = com.sun.star.awt.Key.NUM5; break;
78             case( java.awt.event.KeyEvent.VK_NUMPAD6 ):
79             case( java.awt.event.KeyEvent.VK_6 ):       nRet = com.sun.star.awt.Key.NUM6; break;
80             case( java.awt.event.KeyEvent.VK_NUMPAD7 ):
81             case( java.awt.event.KeyEvent.VK_7 ):       nRet = com.sun.star.awt.Key.NUM7; break;
82             case( java.awt.event.KeyEvent.VK_NUMPAD8 ):
83             case( java.awt.event.KeyEvent.VK_8 ):       nRet = com.sun.star.awt.Key.NUM8; break;
84             case( java.awt.event.KeyEvent.VK_NUMPAD9 ):
85             case( java.awt.event.KeyEvent.VK_9 ):       nRet = com.sun.star.awt.Key.NUM9; break;
86 
87             case( java.awt.event.KeyEvent.VK_A ): nRet = com.sun.star.awt.Key.A; break;
88             case( java.awt.event.KeyEvent.VK_B ): nRet = com.sun.star.awt.Key.B; break;
89             case( java.awt.event.KeyEvent.VK_C ): nRet = com.sun.star.awt.Key.C; break;
90             case( java.awt.event.KeyEvent.VK_D ): nRet = com.sun.star.awt.Key.D; break;
91             case( java.awt.event.KeyEvent.VK_E ): nRet = com.sun.star.awt.Key.E; break;
92             case( java.awt.event.KeyEvent.VK_F ): nRet = com.sun.star.awt.Key.F; break;
93             case( java.awt.event.KeyEvent.VK_G ): nRet = com.sun.star.awt.Key.G; break;
94             case( java.awt.event.KeyEvent.VK_H ): nRet = com.sun.star.awt.Key.H; break;
95             case( java.awt.event.KeyEvent.VK_I ): nRet = com.sun.star.awt.Key.I; break;
96             case( java.awt.event.KeyEvent.VK_J ): nRet = com.sun.star.awt.Key.J; break;
97             case( java.awt.event.KeyEvent.VK_K ): nRet = com.sun.star.awt.Key.K; break;
98             case( java.awt.event.KeyEvent.VK_L ): nRet = com.sun.star.awt.Key.L; break;
99             case( java.awt.event.KeyEvent.VK_M ): nRet = com.sun.star.awt.Key.M; break;
100             case( java.awt.event.KeyEvent.VK_N ): nRet = com.sun.star.awt.Key.N; break;
101             case( java.awt.event.KeyEvent.VK_O ): nRet = com.sun.star.awt.Key.O; break;
102             case( java.awt.event.KeyEvent.VK_P ): nRet = com.sun.star.awt.Key.P; break;
103             case( java.awt.event.KeyEvent.VK_Q ): nRet = com.sun.star.awt.Key.Q; break;
104             case( java.awt.event.KeyEvent.VK_R ): nRet = com.sun.star.awt.Key.R; break;
105             case( java.awt.event.KeyEvent.VK_S ): nRet = com.sun.star.awt.Key.S; break;
106             case( java.awt.event.KeyEvent.VK_T ): nRet = com.sun.star.awt.Key.T; break;
107             case( java.awt.event.KeyEvent.VK_U ): nRet = com.sun.star.awt.Key.U; break;
108             case( java.awt.event.KeyEvent.VK_V ): nRet = com.sun.star.awt.Key.V; break;
109             case( java.awt.event.KeyEvent.VK_W ): nRet = com.sun.star.awt.Key.W; break;
110             case( java.awt.event.KeyEvent.VK_X ): nRet = com.sun.star.awt.Key.X; break;
111             case( java.awt.event.KeyEvent.VK_Y ): nRet = com.sun.star.awt.Key.Y; break;
112             case( java.awt.event.KeyEvent.VK_Z ): nRet = com.sun.star.awt.Key.Z; break;
113 
114             case( java.awt.event.KeyEvent.VK_F1 ): nRet = com.sun.star.awt.Key.F1; break;
115             case( java.awt.event.KeyEvent.VK_F2 ): nRet = com.sun.star.awt.Key.F2; break;
116             case( java.awt.event.KeyEvent.VK_F3 ): nRet = com.sun.star.awt.Key.F3; break;
117             case( java.awt.event.KeyEvent.VK_F4 ): nRet = com.sun.star.awt.Key.F4; break;
118             case( java.awt.event.KeyEvent.VK_F5 ): nRet = com.sun.star.awt.Key.F5; break;
119             case( java.awt.event.KeyEvent.VK_F6 ): nRet = com.sun.star.awt.Key.F6; break;
120             case( java.awt.event.KeyEvent.VK_F7 ): nRet = com.sun.star.awt.Key.F7; break;
121             case( java.awt.event.KeyEvent.VK_F8 ): nRet = com.sun.star.awt.Key.F8; break;
122             case( java.awt.event.KeyEvent.VK_F9 ): nRet = com.sun.star.awt.Key.F9; break;
123             case( java.awt.event.KeyEvent.VK_F10 ): nRet = com.sun.star.awt.Key.F10; break;
124             case( java.awt.event.KeyEvent.VK_F11 ): nRet = com.sun.star.awt.Key.F11; break;
125             case( java.awt.event.KeyEvent.VK_F12 ): nRet = com.sun.star.awt.Key.F12; break;
126             case( java.awt.event.KeyEvent.VK_F13 ): nRet = com.sun.star.awt.Key.F13; break;
127             case( java.awt.event.KeyEvent.VK_F14 ): nRet = com.sun.star.awt.Key.F14; break;
128             case( java.awt.event.KeyEvent.VK_F15 ): nRet = com.sun.star.awt.Key.F15; break;
129             case( java.awt.event.KeyEvent.VK_F16 ): nRet = com.sun.star.awt.Key.F16; break;
130             case( java.awt.event.KeyEvent.VK_F17 ): nRet = com.sun.star.awt.Key.F17; break;
131             case( java.awt.event.KeyEvent.VK_F18 ): nRet = com.sun.star.awt.Key.F18; break;
132             case( java.awt.event.KeyEvent.VK_F19 ): nRet = com.sun.star.awt.Key.F19; break;
133             case( java.awt.event.KeyEvent.VK_F20 ): nRet = com.sun.star.awt.Key.F20; break;
134             case( java.awt.event.KeyEvent.VK_F21 ): nRet = com.sun.star.awt.Key.F21; break;
135             case( java.awt.event.KeyEvent.VK_F22 ): nRet = com.sun.star.awt.Key.F22; break;
136             case( java.awt.event.KeyEvent.VK_F23 ): nRet = com.sun.star.awt.Key.F23; break;
137             case( java.awt.event.KeyEvent.VK_F24 ): nRet = com.sun.star.awt.Key.F24; break;
138 
139             case( java.awt.event.KeyEvent.VK_UP ):          nRet = com.sun.star.awt.Key.UP; break;
140             case( java.awt.event.KeyEvent.VK_DOWN):         nRet = com.sun.star.awt.Key.DOWN; break;
141             case( java.awt.event.KeyEvent.VK_LEFT ):        nRet = com.sun.star.awt.Key.LEFT; break;
142             case( java.awt.event.KeyEvent.VK_RIGHT ):       nRet = com.sun.star.awt.Key.RIGHT; break;
143 
144             case( java.awt.event.KeyEvent.VK_HOME ):        nRet = com.sun.star.awt.Key.HOME; break;
145             case( java.awt.event.KeyEvent.VK_END ):         nRet = com.sun.star.awt.Key.END; break;
146 
147             case( java.awt.event.KeyEvent.VK_PAGE_UP ):     nRet = com.sun.star.awt.Key.PAGEUP; break;
148             case( java.awt.event.KeyEvent.VK_PAGE_DOWN ):   nRet = com.sun.star.awt.Key.PAGEDOWN; break;
149 
150             case( java.awt.event.KeyEvent.VK_ENTER ):       nRet = com.sun.star.awt.Key.RETURN; break;
151             case( java.awt.event.KeyEvent.VK_ESCAPE ):      nRet = com.sun.star.awt.Key.ESCAPE; break;
152 
153             case( java.awt.event.KeyEvent.VK_TAB ):         nRet = com.sun.star.awt.Key.TAB; break;
154     	    case( java.awt.event.KeyEvent.VK_BACK_SPACE ):  nRet = com.sun.star.awt.Key.BACKSPACE; break;
155     	    case( java.awt.event.KeyEvent.VK_SPACE ):       nRet = com.sun.star.awt.Key.SPACE; break;
156     	    case( java.awt.event.KeyEvent.VK_INSERT):       nRet = com.sun.star.awt.Key.INSERT; break;
157     	    case( java.awt.event.KeyEvent.VK_DELETE):       nRet = com.sun.star.awt.Key.DELETE; break;
158     	    case( java.awt.event.KeyEvent.VK_ADD ):         nRet = com.sun.star.awt.Key.ADD; break;
159     	    case( java.awt.event.KeyEvent.VK_SUBTRACT ):    nRet = com.sun.star.awt.Key.SUBTRACT; break;
160     	    case( java.awt.event.KeyEvent.VK_MULTIPLY ):    nRet = com.sun.star.awt.Key.MULTIPLY; break;
161     	    case( java.awt.event.KeyEvent.VK_DIVIDE ):      nRet = com.sun.star.awt.Key.DIVIDE; break;
162     	    case( java.awt.event.KeyEvent.VK_DECIMAL ):     nRet = com.sun.star.awt.Key.POINT; break;
163     	    // case( java.awt.event.KeyEvent.VK_ COMMA; break;
164     	    case( java.awt.event.KeyEvent.VK_LESS ):        nRet = com.sun.star.awt.Key.LESS; break;
165     	    case( java.awt.event.KeyEvent.VK_GREATER ):     nRet = com.sun.star.awt.Key.GREATER; break;
166         	case( java.awt.event.KeyEvent.VK_EQUALS ):      nRet = com.sun.star.awt.Key.EQUAL; break;
167     	    // case( java.awt.event.KeyEvent.VK_ OPEN; break;
168     	    // case( java.awt.event.KeyEvent.VK_ CUT; break;
169         	// case( java.awt.event.KeyEvent.VK_ COPY; break;
170     	    // case( java.awt.event.KeyEvent.VK_ PASTE; break;
171     	    // case( java.awt.event.KeyEvent.VK_ UNDO; break;
172         	// case( java.awt.event.KeyEvent.VK_ REPEAT; break;
173     	    // case( java.awt.event.KeyEvent.VK_ FIND; break;
174     	    // case( java.awt.event.KeyEvent.VK_ PROPERTIES; break;
175     	    // case( java.awt.event.KeyEvent.VK_ FRONT; break;
176     	    // case( java.awt.event.KeyEvent.VK_ CONTEXTMENU; break;
177     	    // case( java.awt.event.KeyEvent.VK_ HELP; break;
178 
179             default:
180             break;
181          }
182 
183          return nRet;
184     }
185 
186     //----------------------------------------------------------------------------------
187 
fireKeyEvent( java.awt.event.KeyEvent aEvt )188     public void fireKeyEvent( java.awt.event.KeyEvent aEvt )
189     {
190         if( maKeyListeners.size() > 0 )
191         {
192             boolean bProcess = false, bPressed = false;
193 
194             if( java.awt.event.KeyEvent.KEY_PRESSED == aEvt.getID() )
195             {
196                 switch( aEvt.getKeyCode() )
197                 {
198                     case( java.awt.event.KeyEvent.VK_SHIFT ): mbShift = true; break;
199                     case( java.awt.event.KeyEvent.VK_CONTROL ): mbMod1 = true; break;
200                     case( java.awt.event.KeyEvent.VK_ALT ): mbMod2 = true; break;
201 
202                     default:
203                     {
204                         bProcess = bPressed = true;
205                     }
206                     break;
207                 }
208             }
209             else if( java.awt.event.KeyEvent.KEY_RELEASED == aEvt.getID() )
210             {
211                 switch( aEvt.getKeyCode() )
212                 {
213                     case( java.awt.event.KeyEvent.VK_SHIFT ): mbShift = false; break;
214                     case( java.awt.event.KeyEvent.VK_CONTROL ): mbMod1 = false; break;
215                     case( java.awt.event.KeyEvent.VK_ALT ): mbMod2 = false; break;
216 
217                     default:
218                     {
219                         bProcess = true;
220                     }
221                     break;
222                 }
223             }
224 
225             if( bProcess )
226             {
227                 KeyEvent aUNOEvt = new KeyEvent();
228 
229                 aUNOEvt.Modifiers = 0;
230 
231                 if( mbShift )
232                     aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT;
233 
234                 if( mbMod1 )
235                     aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD1;
236 
237                 if( mbMod2 )
238                     aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD2;
239 
240                 aUNOEvt.KeyCode = implGetUNOKeyCode( aEvt.getKeyCode() );
241                 aUNOEvt.KeyChar = aEvt.getKeyChar();
242                 aUNOEvt.KeyFunc = com.sun.star.awt.KeyFunction.DONTKNOW;
243 
244                 ListIterator aIter = maKeyListeners.listIterator( 0 );
245 
246                 while( aIter.hasNext() )
247                 {
248                     if( bPressed )
249                         ( (XKeyListener) aIter.next() ).keyPressed( aUNOEvt );
250                     else
251                         ( (XKeyListener) aIter.next() ).keyReleased( aUNOEvt );
252                 }
253             }
254         }
255     }
256 
257     //----------------------------------------------------------------------------------
258 
fireMouseEvent( java.awt.event.MouseEvent aEvt )259     public void fireMouseEvent( java.awt.event.MouseEvent aEvt )
260     {
261         MouseEvent aUNOEvt = new MouseEvent();
262 
263         aUNOEvt.Modifiers = 0;
264         aUNOEvt.Buttons = 0;
265         aUNOEvt.X = aEvt.getX();
266         aUNOEvt.Y = aEvt.getY();
267      	aUNOEvt.PopupTrigger = false;
268 
269         // Modifiers
270         if( aEvt.isShiftDown() )
271             aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT;
272 
273         if( aEvt.isControlDown() )
274             aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD1;
275 
276         if( aEvt.isAltDown() )
277             aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD2;
278 
279         // Buttons
280         if( SwingUtilities.isLeftMouseButton( aEvt ) )
281             aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.LEFT;
282 
283         if( SwingUtilities.isMiddleMouseButton( aEvt ) )
284             aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.MIDDLE;
285 
286         if( SwingUtilities.isRightMouseButton( aEvt ) )
287             aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.RIGHT;
288 
289         // event type
290         if( java.awt.event.MouseEvent.MOUSE_PRESSED == aEvt.getID() )
291         {
292             ListIterator aIter = maMouseListeners.listIterator( 0 );
293 
294             aUNOEvt.ClickCount = 1;
295 
296             while( aIter.hasNext() )
297                 ( (XMouseListener) aIter.next() ).mousePressed( aUNOEvt );
298         }
299         else if( java.awt.event.MouseEvent.MOUSE_RELEASED == aEvt.getID() )
300         {
301             ListIterator aIter = maMouseListeners.listIterator( 0 );
302 
303             aUNOEvt.ClickCount = 1;
304 
305             while( aIter.hasNext() )
306                 ( (XMouseListener) aIter.next() ).mouseReleased( aUNOEvt );
307         }
308         else if( java.awt.event.MouseEvent.MOUSE_DRAGGED == aEvt.getID() )
309         {
310             ListIterator aIter = maMouseMotionListeners.listIterator( 0 );
311 
312             aUNOEvt.ClickCount = 0;
313 
314             while( aIter.hasNext() )
315                 ( (XMouseMotionListener) aIter.next() ).mouseDragged( aUNOEvt );
316         }
317         else if( java.awt.event.MouseEvent.MOUSE_MOVED == aEvt.getID() )
318         {
319             ListIterator aIter = maMouseMotionListeners.listIterator( 0 );
320 
321             aUNOEvt.ClickCount = 0;
322 
323             while( aIter.hasNext() )
324                 ( (XMouseMotionListener) aIter.next() ).mouseMoved( aUNOEvt );
325         }
326     }
327 
328     //----------------------------------------------------------------------------------
329 
fireFocusEvent( java.awt.event.FocusEvent aEvt )330     public void fireFocusEvent( java.awt.event.FocusEvent aEvt )
331     {
332         if( java.awt.event.FocusEvent.FOCUS_GAINED == aEvt.getID() )
333         {
334             ListIterator aIter = maFocusListeners.listIterator( 0 );
335             FocusEvent   aUNOEvt = new FocusEvent();
336 
337             while( aIter.hasNext() )
338             {
339                 ( (XFocusListener) aIter.next() ).focusGained( aUNOEvt );
340             }
341         }
342     }
343 
344     //----------------------------------------------------------------------------------
345 
fireDisposingEvent()346 	public void fireDisposingEvent()
347 	{
348 		ListIterator aIter = maEventListeners.listIterator( 0 );
349 
350 		while( aIter.hasNext() )
351 		{
352 			( (XEventListener) aIter.next() ).disposing( new com.sun.star.lang.EventObject() );
353 		}
354 	}
355 
356     // --------------------
357     // - XWindow methods  -
358     // --------------------
359 
setPosSize( int X, int Y, int Width, int Height, short Flags )360     public void setPosSize( int X, int Y, int Width, int Height, short Flags )
361     {
362         maFrame.setBounds( X, Y, Width, Height );
363     }
364 
365     //----------------------------------------------------------------------------------
366 
getPosSize( )367     public com.sun.star.awt.Rectangle getPosSize(  )
368     {
369         java.awt.Rectangle bounds = maFrame.getBounds();
370         return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
371     }
372 
373     //----------------------------------------------------------------------------------
374 
setVisible( boolean visible )375     public void setVisible( boolean visible )
376     {
377          maFrame.setVisible( visible );
378     }
379 
380     //----------------------------------------------------------------------------------
381 
setEnable( boolean enable )382     public void setEnable( boolean enable )
383     {
384         maFrame.setEnabled( enable );
385     }
386 
387     //----------------------------------------------------------------------------------
388 
setFocus()389     public void setFocus()
390     {
391     }
392 
393     //----------------------------------------------------------------------------------
394 
addEventListener( XEventListener xListener )395     public void addEventListener( XEventListener xListener )
396     {
397         if( xListener != null )
398             maEventListeners.add( xListener );
399     }
400 
401     //----------------------------------------------------------------------------------
402 
removeEventListener( XEventListener xListener )403     public void removeEventListener( XEventListener xListener )
404     {
405         if( xListener != null )
406             maEventListeners.remove( xListener );
407     }
408 
409     //----------------------------------------------------------------------------------
410 
addWindowListener( XWindowListener xListener )411     public void addWindowListener( XWindowListener xListener )
412     {
413         if( xListener != null )
414             maWindowListeners.add( xListener );
415     }
416 
417     //----------------------------------------------------------------------------------
418 
removeWindowListener( XWindowListener xListener )419     public void removeWindowListener( XWindowListener xListener )
420     {
421         if( xListener != null )
422             maWindowListeners.remove( xListener );
423     }
424 
425     //----------------------------------------------------------------------------------
426 
addFocusListener( XFocusListener xListener )427     public void addFocusListener( XFocusListener xListener )
428     {
429         if( xListener != null )
430             maFocusListeners.add( xListener );
431     }
432 
433     //----------------------------------------------------------------------------------
434 
removeFocusListener( XFocusListener xListener )435     public void removeFocusListener( XFocusListener xListener )
436     {
437         if( xListener != null )
438             maFocusListeners.remove( xListener );
439     }
440 
441     //----------------------------------------------------------------------------------
442 
addKeyListener( XKeyListener xListener )443     public void addKeyListener( XKeyListener xListener )
444     {
445         if( xListener != null )
446             maKeyListeners.add( xListener );
447     }
448 
449     //----------------------------------------------------------------------------------
450 
removeKeyListener( XKeyListener xListener )451     public void removeKeyListener( XKeyListener xListener )
452     {
453         if( xListener != null )
454             maKeyListeners.remove( xListener );
455     }
456 
457     //----------------------------------------------------------------------------------
458 
addMouseListener( XMouseListener xListener )459     public void addMouseListener( XMouseListener xListener )
460     {
461         if( xListener != null )
462             maMouseListeners.add( xListener );
463     }
464 
465     //----------------------------------------------------------------------------------
466 
removeMouseListener( XMouseListener xListener )467     public void removeMouseListener( XMouseListener xListener )
468     {
469         if( xListener != null )
470             maMouseListeners.remove( xListener );
471     }
472 
473     //----------------------------------------------------------------------------------
474 
addMouseMotionListener( XMouseMotionListener xListener )475     public void addMouseMotionListener( XMouseMotionListener xListener )
476     {
477         if( xListener != null )
478             maMouseMotionListeners.add( xListener );
479     }
480 
481     //----------------------------------------------------------------------------------
482 
removeMouseMotionListener( XMouseMotionListener xListener )483     public void removeMouseMotionListener( XMouseMotionListener xListener )
484     {
485         if( xListener != null )
486             maMouseMotionListeners.remove( xListener );
487     }
488 
489     //----------------------------------------------------------------------------------
490 
addPaintListener( XPaintListener xListener )491     public void addPaintListener( XPaintListener xListener )
492     {
493         if( xListener != null )
494             maPaintListeners.add( xListener );
495     }
496 
497     //----------------------------------------------------------------------------------
498 
removePaintListener( XPaintListener xListener )499     public void removePaintListener( XPaintListener xListener )
500     {
501         if( xListener != null )
502             maPaintListeners.remove( xListener );
503     }
504 }
505