say 'This is the date and time of today. You can also see the day in the box above. We wish you both a happy day' -- Create a Java RexxProxy for controlling the closing of the application rexxCloseEH =.RexxCloseAppEventHandler~new -- Rexx event handler -- Create Java RexxProxy for the Rexx event handler rpCloseEH=BsfCreateRexxProxy(rexxCloseEH, , "java.awt.event.ActionListener", - "java.awt.event.WindowListener" ) /*import datetime*/ .bsf~bsf.import("org.oorexx.datergf.DateTimeRGF", "DateTimeRGF") /* bsf.import the Java class*/ .bsf~bsf.import("org.oorexx.datergf.DateFormatRGF", "DateFormatRGF") /* bsf.import the Java class*/ dt1 = .DateTimeRGF~new say dt1~toString dt1~update say dt1~toString say tmpWin = .awtFrame~new('This is the date and time from today:') tmpWin~addWindowListener(rpCloseEH) tmpBut = .bsf~new("java.awt.Button", 'Press Me for having a good day !') tmpBut~addActionListener(rpCloseEH) lab=.bsf~new("java.awt.Label") lab~setAlignment(lab~center) -- set alignment to center text = dt1~toString lab~setText(text) tmpWin ~~add("South", tmpBut) ~~add("Center",lab) ~~pack ~~setVisible(.true) ~~toFront --tmpWin ~~add(tmpBut) ~~pack ~~setVisible(.true) ~~toFront rexxCloseEH~waitForExit -- if Java was loaded by Rexx, then terminate Java's RexxEngine to inhibit callbacks from Java call BSF.terminateRexxEngine ::REQUIRES BSF.CLS /* one way, how to define a Java class in Object Rexx */ ::CLASS "awtFrame" SUBCLASS bsf ::METHOD init self~init:super('java.awt.Frame', ARG(1, 'A')) /* ------------------------------------------------------------------------ */ /* Rexx event handler to set "close app" indicator */ ::class RexxCloseAppEventHandler ::method init /* constructor */ expose closeApp closeApp = .false -- if set to .true, then it is safe to close the app ::attribute closeApp -- indicates whether app should be closed ::method unknown -- intercept unhandled events, do nothing ::method actionPerformed -- event method (from ActionListener) expose closeApp closeApp=.true -- indicate that the app should close ::method windowClosing -- event method (from WindowListener) expose closeApp closeApp=.true -- indicate that the app should close ::method waitForExit -- method blocks until attribute is set to .true expose closeApp guard on when closeApp=.true