PROGRAM JWINDOW!       Example window.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-15  Time: 16:37:12

USE JAPI 

INTEGER :: frame,obj
INTEGER :: window,label,released,pressed
INTEGER :: x,y,fx,fy
CHARACTER (LEN=256) :: message

CALL j_setdebug(-3)

IF( .NOT. j_start()) THEN
  PRINT*, "can't connect to JAPI server"
  GO TO 20
END IF

!       Generate Graphic Objects
frame   = j_frame("Window Demo")

window  = j_window(frame)
CALL j_setflowlayout(window,j_horizontal)
label   = j_label(window,"")
CALL j_setnamedcolorbg(label,j_yellow)

pressed  = j_mouselistener(frame,j_pressed)
released = j_mouselistener(frame,j_released)

CALL j_show(frame)
NEXTACTION: DO
      obj =  j_nextaction()

IF(obj == frame) EXIT NEXTACTION

IF(obj == pressed) THEN
  CALL j_getpos(frame,fx,fy)
  CALL j_getmousepos(pressed,x,y)
  WRITE(unit=message,fmt="(a,i3,a,i3)") "Mouse pressed at ",x,":",y
  CALL j_settext(label,message)
  CALL j_setpos(window,fx+x,fy+y)
  CALL j_pack(window)
  CALL j_show(window)
END IF

IF(obj == released) CALL j_hide(window)

END DO NEXTACTION

20  continue
CALL j_quit()
END PROGRAM JWINDOW
