PROGRAM GRIDLAYOUT!       Example gridlayout.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-15  Time: 00:37:36

USE JAPI


INTEGER :: frame,grid,button1,button2,button3,button4,obj

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

!       Generate Graphical Objects
frame    = j_frame("Grid Layout Demo")

CALL j_setgridlayout(frame,2,2)
grid     = j_getlayoutid(frame)

button1  = j_button(frame,"button1")
button2  = j_button(frame,"button2")
button3  = j_button(frame,"button3")
button4  = j_button(frame,"button4")

CALL j_sethgap(frame,20)
CALL j_setvgap(frame,5)

CALL j_setsize(button1,200,100)

CALL j_pack(frame)
CALL j_show(frame)

NEXTACTION: DO
    obj=j_nextaction()

    IF(obj == frame) EXIT NEXTACTION

    IF(obj == button1) THEN
        CALL j_setrows(grid,4)
        CALL j_setcolumns(grid,1)
	END IF
    
    IF(obj == button2) THEN
        CALL j_setrows(grid,1)
        CALL j_setcolumns(grid,4)
	END IF
    
    IF(obj == button3) THEN
        CALL j_setrows(grid,3)
        CALL j_setcolumns(grid,1)
	END IF
    
    IF(obj == button4) THEN
        CALL j_setrows(grid,2)
        CALL j_setcolumns(grid,2)
	END IF
          
    CALL j_pack(frame)    	
END DO NEXTACTION

20   continue

CALL j_quit()
END PROGRAM GRIDLAYOUT

