REM Demo program for controlling BBjApplet through AppletProxy
REM Obtain the instance of the BBjAPI object LET myAPI!=BBjAPI()
REM Open the SysGui device SYSGUI=UNT OPEN (SYSGUfI) "X0"
REM Obtain the instance of the BBjSysGui object LET mySysGui!=myAPI!.getSysGui()
REM Set addWindow param values X=0 Y=0 WIDTH=960 HEIGHT=100 TITLE$="BBj Window"
REM Set the current context mySysGui!.setContext(0)
REM Create a window myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$)
REM Add buttons to the window changeSize! = myWindow!.addButton(101,20,20,100,20,"be Large",$0800$) innerFrame! = myWindow!.addButton(102,140,20,140,20,"show Internal Frame",$0800$) outerFrame! = myWindow!.addButton(103,300,20,140,20,"show External Frame",$0800$) text! = myWindow!.addStaticText(104,460,10,189,10,"select item to display on status bar") listBox! = myWindow!.addListBox(105,460,25,160,50,"",$0000$) listBox!.addItem("Program Name") listBox!.addItem("Config file") listBox!.addItem("AppServerPort")
REM set their colors and text green! = mySysGui!.makeColor(mySysGui!.GREEN) blue! = mySysGui!.makeColor(mySysGui!.LTGRAY) magenta! = mySysGui!.makeColor(mySysGui!.MAGENTA) changeSize!.setBackColor(green!) innerFrame!.setBackColor(blue!) outerFrame!.setBackColor(magenta!)
REM get AppletProxy and use it to set bounds of Applet applet! = BBjApi().getAppletProxy() applet!.setBounds(200,200,140,100)
REM define some boolean values isLarge = 0 showingInnerFrame = 0 showingGoogle = 0
REM Register the CALLBACK routines CALLBACK(ON_BUTTON_PUSH,CHANGE_SIZE,mySysGui!.getContext(),changeSize!.getID()) CALLBACK(ON_BUTTON_PUSH,DO_INNER_FRAME,mySysGui!.getContext(),innerFrame!.getID()) CALLBACK(ON_BUTTON_PUSH,DO_OUTER_FRAME,mySysGui!.getContext(),outerFrame!.getID()) CALLBACK(ON_LIST_CLICK,DO_LIST_BOX,mySysGui!.getContext(),listBox!.getID()) CALLBACK(ON_LIST_DOUBLE_CLICK,DO_LIST_BOX,mySysGui!.getContext(),listBox!.getID()) CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())
REM Process Events PROCESS_EVENTS
CHANGE_SIZE: REM escape if(isLarge)
escape x! = javax.swing.UIManager.getLookAndFeel() ?x!.toString() java.lang.System.out.println(x!.toString()) changeSize!.setText("Enlarge Applet") isLarge = 0 applet!.showStatus("Shrinking Applet....") program$ = applet!.getParam("BBjProgram") applet!.setBounds(200,200,140,100) else isLarge = 1 changeSize!.setText("Shrink Applet") applet!.showStatus("Enlarging Applet") if showingInnerFrame applet!.setBounds(0,0,960,620) else applet!.setBounds(0,0,960,100) endif endif RETURN
DO_INNER_FRAME: if(showingInnerFrame) applet!.setBounds(0,0,960,100) innerFrame!.setText("show internal frame") applet!.showStatus("inner frame removed....") applet!.removeFrame("frame1") showingInnerFrame = 0 else applet!.setBounds(0,0,960,620) applet!.addFrame(0,100,960,520,"http://www.google.com","frame1") innerFrame!.setText("remove internal frame") applet!.showStatus("internal frame added") showingInnerFrame = 1 endif RETURN
DO_OUTER_FRAME: if(showingGoogle) applet!.showDocument("http://www.poweredByBBj.com", "frame_1") applet!.showStatus("showing www.poweredByBBj.com in external frame") outerFrame!.setText("Show google.com") showingGoogle = 0 else applet!.showDocument("http://www.google.com", "frame_1") applet!.showStatus("showing www.google.com in external frame") outerFrame!.setText("Show poweredByBBj.com") showingGoogle = 1 endif RETURN
DO_LIST_BOX:
applet!.playAudio("file://c:\winnt\media\tada.wav") switch listBox!.getSelectedIndex() case 0 message$ = "BBjProgram: " + applet!.getParam("BBjProgram") break case 1 message$ = "BBjConfig: " + applet!.getParam("BBjConfig") break case 2 message$ = "AppServerPort: " + applet!.getParam("AppServerPort") break swend applet!.showStatus(message$) return
REM Callback routine called when the user closes the application window APP_CLOSE: RELEASE RETURN
|