PROGRAM JCHECKBOX!       Example checkbox.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-14  Time: 20:35:01


USE JAPI

INTEGER :: frame,menubar,FILE,quit,obj
INTEGER :: blue,red,green
INTEGER :: r,g,b

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

frame   = j_frame("switch the colors On/Off")
menubar = j_menubar(frame)
FILE    = j_menu(menubar,"File")
quit    = j_menuitem(FILE,"Quit")

blue=j_checkbox(frame,"Blue")
CALL j_setpos(blue,150,80)
CALL j_setstate(blue, .true. )
b=255

red=j_checkbox(frame,"Red")
CALL j_setpos(red,150,120)
CALL j_setstate(red, .false. )
r=0

green=j_checkbox(frame,"Green")
CALL j_setpos(green,150,160)
CALL j_setstate(green, .false. )
g=0

CALL j_setcolorbg(frame,r,g,b)
CALL j_show(frame)

NEXTACTION: DO
      obj=j_nextaction()

IF(obj == blue) THEN
  IF(j_getstate(blue)) THEN
    b=255
  ELSE
    b=0
  END IF
END IF

IF(obj == red) THEN
  IF(j_getstate(red)) THEN
    r=255
  ELSE
    r=0
  END IF
END IF

IF(obj == green) THEN
  IF(j_getstate(green)) THEN
    g=255
  ELSE
    g=0
  END IF
END IF

CALL j_setcolorbg(frame,r,g,b)

IF(r+g+b < 256) THEN
  CALL j_setcolor(frame,255,255,255)
ELSE
  CALL j_setcolor(frame,0,0,0)
END IF

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

END DO NEXTACTION

20   CONTINUE
CALL j_quit()
END PROGRAM JCHECKBOX

