If BsfInvokedBy()=1 then say "This Rexx program was invoked by Java!" else if BsfInvokedBy()=2 then say "This Rexx program was invoked by Rexx, JVM loaded by Rexx!" else say "No JVM present, we got troubles ..." userData=.directory~new rexxCloseEH=.RexxCloseAppEventHandler~new rpCloseEH=BsfCreateRexxProxy(rexxCloseEH, , "java.awt.event.ActionListener", - "java.awt.event.WindowListener") .BSF~bsf.import('java.awt.Button' , 'awtButton' ) .BSF~bsf.import('java.awt.Choice' , 'awtChoice' ) .BSF~bsf.import('java.awt.Color' , 'awtColor' ) .BSF~bsf.import('java.awt.Frame' , 'awtFrame' ) .BSF~bsf.import('java.awt.GridLayout', 'awtGridLayout' ) .BSF~bsf.import('java.awt.Label' , 'awtLabel' ) .BSF~bsf.import('java.awt.TextField' , 'awtTextField' ) label3 = .awtLabel~new('Richtung der Berechnung') choice = .awtChoice~new choice~~addItem('cm zu zoll')~~addItem('zoll zu cm') userData~choice = choice OK = .awtButton~new('Berechnen') rpOk=BsfCreateRexxProxy(.RexxOkHandler2~new, userData, "java.awt.event.ActionListener") ok~addActionListener(rpOk) cancel = .awtButton~new('Abbrechen') cancel~addActionListener(rpCloseEH) background = .awtColor~newStrict("int", 150, "int", 150, "int", 250) gLayout = .awtGridLayout~new(5, 2) window = .awtFrame~new('Von Zoll zu Cm und vice versa :)') window~addWindowListener(rpCloseEH) window~setLayout(GLayout) window~~add(Label3)~~add(choice) window~~add(OK) ~~add(Cancel) window ~~setSize(550, 150) ~~setLocation(300, 250) ~~setVisible(.true) ~~toFront drop label3 rexxCloseEH~waitForExit window~dispose call syssleep .25 call BSF.terminateRexxEngine ::REQUIRES BSF.CLS ::ROUTINE calculate use arg userData window2 = .awtFrame~new("Dein Ergebnis") label = .awtLabel~new ende = .awtButton~new('Beenden') window2~~add('North', label)~~add('South', ende) choice = userData~choice~getSelectedItem eingabe = userData~eingabe~getText if choice = "cm zu zoll" then label~setText(eingabe " Centimeter sind "eingabe * 0.393701 " Zoll" ) if choice = "zoll zu cm" then label~setText(eingabe " Zoll sind " eingabe * 2.54 " Centimeter") window2 ~~setSize(400, 100) ~~setLocation(250, 100) ~~setVisible(.true) ~~toFront rexxCloseEH=.RexxClosePopupEventHandler~new rp=BsfCreateRexxProxy(rexxCloseEH, , "java.awt.event.ActionListener", - "java.awt.event.WindowListener") window2~addWindowListener(rp) ende~addActionListener(rp) rexxcloseEH~waitForExit window2~dispose ::ROUTINE eingabe use arg userData window3 = .awtFrame~new("Eingabe..") label1 = .awtLabel~new ende = .awtButton~new('Beenden') label2 = .awtLabel~new eingabe = .awtTextField~new userData~eingabe = eingabe calc = .awtButton~new('Berechnen') calcrp=BsfCreateRexxProxy(.RexxOkHandler~new, userData, "java.awt.event.ActionListener") calc~addActionListener(calcrp) choice = userData~choice~getSelectedItem if choice = "cm zu zoll" then label2~setText("Bitte gib cm ein..." ) if choice = "zoll zu cm" then label2~setText("Bitte gib Zoll ein..." ) window3~~add('North', label2)~~add('South', ende) window3~~add(eingabe) ~~add('South', calc) window3 ~~setSize(400, 100) ~~setLocation(250, 100) ~~setVisible(.true) ~~toFront rexxCloseEH=.RexxClosePopupEventHandler~new rp=BsfCreateRexxProxy(rexxCloseEH, , "java.awt.event.ActionListener", - "java.awt.event.WindowListener") window3~addWindowListener(rp) ende~addActionListener(rp) rexxcloseEH~waitForExit window3~dispose ::class RexxCloseAppEventHandler ::method init expose closeApp closeApp = .false ::attribute closeApp ::method unknown ::method actionPerformed expose closeApp closeApp=.true ::method windowClosing expose closeApp closeApp=.true ::method waitForExit expose closeApp guard on when closeApp=.true ::class RexxOkHandler ::method actionPerformed use arg eventObject, slotDir reply call calculate slotDir~userData ::class RexxOkHandler2 ::method actionPerformed use arg eventObject, slotDir reply call eingabe slotDir~userData ::class RexxClosePopupEventHandler ::method init expose closeApp closeApp = .false ::attribute closeApp ::method unknown ::method actionPerformed expose closeApp closeApp=.true ::method windowClosing expose closeApp closeApp=.true ::method waitForExit expose closeApp guard on when closeApp=.true