BBjAppletProxy

Description

The BBjAppletProxy provides control of the Applet and AppletContext when a BBj program is being run through an Applet.

Creation

BBjAPI > BBjAppletProxy

The BBjAppletProxy object is created through the following BBjAPI object method:

Return Value

Method

BBjAppletProxy

getAppletProxy()

 

Methods of BBjAppletProxy

Return Value

Method

void

setBounds(int x, int y, int width, int height)

string

getParam(string paramName)

void

showDocument(string URLName, string frameName)

void

showStatus(string statusMessage)

void

playAudio(string URLName)

void

playAudio(string URLName, string relativeName)

void

addFrame(int x, int y, int width, int height, string URLName, string frameName)

void

removeFrame(string frameName)

 

Remarks

A BBj program cannot obtain an Applet Proxy if the program is not being run from within an Applet environment (BBjAPI().getAppletProxy will fail).

Constants

None.

Example

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 (SYSGUI) "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)
        x! = javax.swing.UIManager.getLookAndFeel()
        print 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

See Also

BBjAPI

BBj Object Variables

BBj Object Assignment

BBj Object Error Handling

BBj Object Operators

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.