PROGRAM JCHOICE!       Example choice.f

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


USE JAPI

INTEGER :: frame,obj
INTEGER :: choice,color

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

!       Generate Graphical Objects
frame   = j_frame("select a color")

choice  = j_choice(frame)

CALL j_additem(choice,"Red")
CALL j_additem(choice,"Green")
CALL j_additem(choice,"Blue")
CALL j_additem(choice,"Yellow")
CALL j_additem(choice,"White")
CALL j_additem(choice,"Black")
CALL j_additem(choice,"Magenta")
CALL j_additem(choice,"Orange")

CALL j_setpos(choice,150,120)

CALL j_select(choice,3)
CALL j_setnamedcolorbg(frame,j_yellow)

CALL j_show(frame)

!       Waiting for actions */
NEXTACTION: DO
      obj=j_nextaction()

IF(obj == choice) THEN
  color=j_getselect(choice)
  
  IF(color == 0) CALL j_setnamedcolorbg(frame,j_red)
  IF(color == 1) CALL j_setnamedcolorbg(frame,j_green)
  IF(color == 2) CALL j_setnamedcolorbg(frame,j_blue)
  IF(color == 3) CALL j_setnamedcolorbg(frame,j_yellow)
  IF(color == 4) CALL j_setnamedcolorbg(frame,j_white)
  IF(color == 5) CALL j_setnamedcolorbg(frame,j_black)
  IF(color == 6) CALL j_setnamedcolorbg(frame,j_magenta)
  IF(color == 7) CALL j_setnamedcolorbg(frame,j_orange)
END IF

IF(obj == frame) EXIT

END DO NEXTACTION

20   CONTINUE
CALL j_quit()
END PROGRAM JCHOICE


