program mousebuttons

use japi
 	
    integer :: frame,dclick,obj
   
    if( .not. j_start()) then
        print*, "can't connect to JAPI server"   
        goto 20
    endif
 
    frame     = j_frame("doubleclick the frame")
    call j_show(frame)

    dclick    = j_mouselistener(frame,J_DOUBLECLICK)

    nextaction: do

       obj=j_nextaction()
           
       if(obj == dclick) then
          if(j_getmousebutton(dclick) == J_LEFT)   call j_settext(frame,"Left Mousebutton")
          if(j_getmousebutton(dclick) == J_CENTER) call j_settext(frame,"Middle Mousebutton")
          if(j_getmousebutton(dclick) == J_RIGHT)  call j_settext(frame,"Right Mousebutton")
       endif
 	   
       if(obj == frame) goto 20

    enddo nextaction
   
20  continue
    call j_quit()
        
end program mousebuttons

