PROGRAM FILEDIALOG

USE JAPI


INTEGER :: frame,menubar,FILE,OPEN,SAVE,quit,obj
CHARACTER (LEN=256) :: filename

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

frame    = j_frame("Filedialog Demo")
menubar  = j_menubar(frame)
FILE     = j_menu(menubar,"File")
OPEN     = j_menuitem(FILE,"Open")
SAVE     = j_menuitem(FILE,"Save")
quit     = j_menuitem(FILE,"Quit")

CALL j_show(frame)
filename = "images"

NEXTACTION: DO
  
  obj =  j_nextaction()

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

  IF(obj == OPEN) THEN
     CALL j_filedialog(frame,"Open File",filename)
     print*, "Open File ",filename
  END IF

  IF(obj == SAVE) THEN
     CALL j_filedialog(frame,"Save File",filename)
     print*, "Save File ",filename
  END IF

END DO NEXTACTION

20  continue
CALL j_quit()
END PROGRAM FILEDIALOG
