#!/usr/bin/env rexx rxApp=.RexxApplication~new -- create Rexx object that will control the FXML set up -- rxApp will be used for "javafx.application.Application" jrxApp=BSFCreateRexxProxy(rxApp, ,"javafx.application.Application") jrxApp~launch(jrxApp~getClass, .nil) -- launch the application, invokes "start" ::requires "BSF.CLS" -- get Java support -- Rexx class defines "javafx.application.Application" abstract method "start" ::class RexxApplication -- implements the abstract class "javafx.application.Application" ::method start -- Rexx method "start" implements the abstract method use arg primaryStage -- fetch the primary stage (window) primaryStage~setTitle("Current Time (Red and Green Version)") -- get Java class objects to ease access to their constants (static fields) colorClz=bsf.loadClass("javafx.scene.paint.Color") -- JavaFX colors cdClz=bsf.loadClass("javafx.scene.control.ContentDisplay") -- ContentDisplay constants alClz=bsf.loadClass("javafx.geometry.Pos") -- alignment constants (an Enum class) root=.bsf~new("javafx.scene.layout.AnchorPane") -- create the root node root~prefHeight=500 -- or: root~setPrefHeight(500) root~prefWidth=300 -- or: root~setPrefWidth(300) -- define the Label lbl=.bsf~new("javafx.scene.control.Label") lbl~textFill=colorClz~GREEN -- or: lbl~setTextFill(colorClz~GREEN) lbl~setLayoutX(20) -- or: lbl~layoutX=76 lbl~setLayoutY(300) -- or: lbl~layoutY=138 lbl~prefHeight="30.0" -- or: lbl~setPrefHeight("16.0") lbl~prefWidth="300.0" -- or: lbl~setPrefWidth("248.0") lbl~contentDisplay=cdClz~CENTER -- or: lbl~setContentDisplay (cdClz~CENTER) lbl~alignment=alClz~valueOf("CENTER") -- or: lbl~setAlignment(alClz~valueOf("CENTER")) -- define and add the Button, assign values as if we deal with Rexx attributes btn=.bsf~new("javafx.scene.control.Button") btn~textFill=colorClz~RED -- or: btn~setTextFill(colorClz~RED) btn~layoutX=120 -- or: btn~setLayoutX(120) btn~layoutY=220 -- or: btn~setLayoutY(220) btn~text="What's the time?" -- or: btn~setText("Click Me!") -- create a Rexx ButtonHandler, wrap it up as a Java RexxProxy rh=.RexxButtonHandler~new(lbl)-- create Rexx object, supply it the label "lbl" jrh=BSFCreateRexxProxy(rh, ,"javafx.event.EventHandler") btn~setOnAction(jrh) -- forwards "handle" message to Rexx object -- add the button and label to the AnchorPane object root~getChildren~~add(btn)~~add(lbl) -- put the scene on the stage primaryStage~setScene(.bsf~new("javafx.scene.Scene", root)) primaryStage~show -- show the stage (window) with the scene -- Rexx class which handles the button presses ::class RexxButtonHandler -- implements "javafx.event.EventHandler" interface ::method init -- Rexx constructor method expose label -- allow direct access to ooRexx attribute use arg label -- save reference to javafx.scene.control.Label ::method handle -- will be invoked by the Java side expose label -- allow direct access to ooRexx attribute, not used in this example -- use arg event, slotDir -- expected arguments now=.dateTime~new -- time of invocation say now": arrived in method 'handle' ..." say '... current value of label='pp(label~getText) label~text="Current Time:" now -- set text property say '... new value of label='pp(label~getText) say