PROGRAM JLABEL!       Example label.f

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

USE JAPI

INTEGER :: frame,menubar,FILE,doit,quit,label,obj
INTEGER :: width,height,x,y,dx,dy
INTEGER :: run

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

frame   = j_frame("Moving Label")

menubar = j_menubar(frame)
FILE    = j_menu(menubar,"File")
doit    = j_menuitem(FILE,"Start")
quit    = j_menuitem(FILE,"Quit")


label   = j_label(frame,"Hello World")
CALL j_setpos(label,10,120)

CALL j_setsize(frame,256,256)
CALL j_show(frame)

width   = j_getwidth(label)
height  = j_getheight(label)

dx=2
dy=1
run=0

NEXTACTION: DO

IF(run == 1) THEN
  obj=j_getaction()
ELSE
  obj=j_nextaction()
END IF

IF((obj == quit) .OR. (obj == frame)) EXIT NEXTACTION

IF(obj == doit) THEN
  IF(run == 0) THEN
    run=1
    CALL j_settext(doit,"Stop")
  ELSE
    run=0
    CALL j_settext(doit,"Start")
  END IF
END IF

IF(run == 1) THEN
  CALL j_getpos(label,x,y)
  IF((x+width  > j_getwidth (frame)) .OR. (x < 1)) dx = -dx
  IF((y+height > j_getheight(frame)) .OR. (y < 1)) dy = -dy
  CALL j_setpos(label,x+dx, y+dy)
  CALL j_sync()
  CALL j_sleep(10)
END IF

END DO NEXTACTION

20      CONTINUE
CALL j_quit()

END PROGRAM JLABEL



