PROGRAM JDIALOG2!       Example dialog.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-14  Time: 21:58:14

USE JAPI


INTEGER :: frame,menubar,FILE,quit,obj
INTEGER :: doit,OPEN
INTEGER :: dialog,label,CLOSE
INTEGER :: x,y


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

!       Generate Graphic Objects
frame   = j_frame("Dialog Demo")
menubar = j_menubar(frame)
FILE    = j_menu(menubar,"File")
quit    = j_menuitem(FILE,"Quit")
doit    = j_menu(menubar,"Do It")
OPEN    = j_menuitem(doit,"Open Dialog")

dialog  = j_dialog(frame,"Say Hello!")
CALL j_setflowlayout(dialog,j_vertical)

label   = j_label(dialog,"Hello World")
CLOSE   = j_button(dialog,"Close")

CALL j_pack(dialog)
CALL j_show(frame)

NEXTACTION: DO
      obj =  j_nextaction()
IF((obj == frame) .OR. (obj == quit)) EXIT

IF(obj == OPEN) THEN
  CALL j_disable(frame)
  
!                in der Mitte von Frame placieren
  CALL j_getpos(frame,x,y)
  x = x+j_getwidth(frame)/2 - j_getwidth(dialog)/2
  y = y+j_getheight(frame)/2 -  j_getheight(dialog)/2
  CALL j_setpos(dialog,x,y)
  CALL j_show(dialog)
END IF

IF((obj == CLOSE) .OR. (obj == dialog)) THEN
  CALL j_hide(dialog)
  CALL j_enable(frame)
END IF

END DO NEXTACTION

20  continue
CALL j_quit()
END PROGRAM JDIALOG2
