Example : Mouselistener

1) Define the communication
    1.1) function name JAPI_MOUSELISTENER ( j_mouselistener() )
    1.2) Arguments
        1.2.1) obj  : integer
        1.2.2) type : J_PRESSED 
                      J_RELEASED
                      J_DRAGGED
                      J_ENTERERD
                      J_MOVED
                      J_EXITED

    1.3) return: int
    
2) java code in java/JAPI_Thread.java
   

                if (command == JAPI_Calls.JAPI_MOUSELISTENER)
                {
                    int kind = in.recvInt();

                    if(debug>0) debugwindow.println("Mouse Listener Type: "+kind+" (ID = "+objectcounter+")  in Parent Object "+o[obj].toString());
                    if(o[obj] instanceof Component)
                    {
                        if(kind==JAPI_Const.J_PRESSED) 
                        {
                           o[objectcounter] = new JGI_Mouselistener(objectcounter,out,action,DOWN);
                           ((Component)o[obj]).addMouseListener((JGI_Mouselistener)o[objectcounter]);
                        }
                        if(kind==JAPI_Const.J_RELEASED) 
                        {   
                           o[objectcounter] = new JGI_Mouselistener(objectcounter,out,action,UP);
                           ((Component)o[obj]).addMouseListener((JGI_Mouselistener)o[objectcounter]);
                           }
                        if(kind==JAPI_Const.J_ENTERERD) 
                        {   
                           o[objectcounter] = new JGI_Mouselistener(objectcounter,out,action,ENTER);
                           ((Component)o[obj]).addMouseListener((JGI_Mouselistener)o[objectcounter]);
                        }
                        if(kind==JAPI_Const.J_EXITED)   
                        {   
                           o[objectcounter] = new JGI_Mouselistener(objectcounter,out,action,EXIT);
                           ((Component)o[obj]).addMouseListener((JGI_Mouselistener)o[objectcounter]);
                        }
                        if(kind==JAPI_Const.J_MOVED)    
                        {   
                            o[objectcounter] = new JGI_Mousemotionlistener(objectcounter,out,action,MOVE);
                            ((Component)o[obj]).addMouseMotionListener((JGI_Mousemotionlistener)o[objectcounter]);
                        }
                        if(kind==JAPI_Const.J_DRAGGED) 
                        {   
                            o[objectcounter] = new JGI_Mousemotionlistener(objectcounter,out,action,DRAG);
                            ((Component)o[obj]).addMouseMotionListener((JGI_Mousemotionlistener)o[objectcounter]);
                        }
                        objectcounter++;
                      }
                      else
                      {
                         if(errordialog.getResult("No Component ID in j_mousepressed( ID )","ID = "+o[obj].toString()))
                            nextaction=false;
                         else
                            out.sendInt(-1);
                      }
                      continue;
                }

3) C code in lib/japilib.c 
                int japi_mouselistener(int component, int kind)
                {   return(send_3int_get_int(JAPI_MOUSELISTENER,component,kind)); }
    
4) define konstants
    4.1) JAPI_MOUSEPRESSED in lib/japicalls.def
    4.2) kind types in lib/japiconst.def
                 COMMENT MOUSELISTENER
                 TYPE  J_PRESSED                   0
                 TYPE  J_RELEASED                  1
                 TYPE  J_DRAGGED                   2
                 TYPE  J_ENTERERD                  3
                 TYPE  J_MOVED                     4
                 TYPE  J_EXITED                    5



5) compile and TEST, TEST and TEST again!

6) documentation
	6.1) write a chapter in the programming manual (optional)
	6.2) write a ref-file in japidoc/reference/refs (needed)
	     
	     j_mouselistener.ref :
	     
             DESC                                                                (NEEDED)
                int j\_mouselistener ( int obj , int kind )  
             ENDDESC

             GER
             SHORT                                                               (NEEDED)
                 Bindet an \ACKCOMPONENT \PARAM{obj} einen neuen Mouselistener, 
                 und liefert dessen Eventnummer zur"uck. Der Parameter 
                 \PARAM{kind} bestimmt, wann ein Event ausgel"ost wird.
             ENDSHORT
             LONG                                                                (OPTIONAL)
             ENDLONG
             ENDGER

             ENG
             SHORT                                                               (NEEDED)
                 Adds a new mouse listener to \COMPONENT \PARAM{obj}, and 
                 returns its event number. An event occures, if the user action 
                 is of kind \PARAM{kind}. 
             ENDSHORT
             LONG                                                                (OPTIONAL)
             ENDLONG
             ENDENG

             OBJECTS                                                             (NEEDED)
                \ALLCOMPONENTS
             ENDOBJECTS

             FEX                                                                 (OPTIONAL)   
             ENDFEX
             PEX                                                                 (OPTIONAL)
             ENDPEX
             CEX                                                                 (OPTIONAL)
             ENDCEX
             BEX                                                                 (OPTIONAL)   
             ENDBEX

             PICTURE                                                             (OPTIONAL)
             ENDPICTURE

             REFS                                                                (OPTIONAL)
             ENDREFS

             ENDPAGE
 
