program vumeter

use japi
  	
        integer :: frame,progress,meter,value

        if( .not. j_start()) then
            print*, "can't connect to JAPI server"   
            goto 20
        endif

        frame = j_frame("Meter")
        call j_setborderlayout(frame)
        call j_setinsets(frame,j_getinsets(frame,J_TOP)+10,10,10,10)
        call j_setvgap(frame,10)

        progress=j_progressbar(frame,J_HORIZONTAL)
        call j_setborderpos(progress,J_BOTTOM)
        meter=j_meter(frame,"Volt")

        call j_setsize(frame,150,170)
        call j_show(frame)

        value=50
        mainloop: do
        
	   if(j_getaction()==frame) goto 20
           value=value-1
           if(j_random()>J_RANDMAX/2) value=value+2
           call j_setvalue(meter,value)
           call j_setvalue(progress,value)
           call j_sync()
           call j_sleep(50)
	end do mainloop

20      continue
        call j_quit()
        end program vumeter
