If we rummage around in PSurfaceFX there is a ‘stage’ so the runtime is already using JavaFX for the FX2D renderer. It is possible to get a javafx control added to a pane container and to make the pane part of a scene, but it chokes when it comes time to set the scene on the stage and show it.
# https://github.com/processing/processing/blob/master/core/src/processing/javafx/PSurfaceFX.java
import javafx.stage.Stage
_wndW = 300
_wndH = 300
def setup():
size(_wndW,_wndH,FX2D)
frame = get_surface()
print("frame =",frame)
pane = javafx.scene.layout.Pane()
btn = javafx.scene.control.Button("btn")
btn.setLayoutX(100)
btn.setLayoutY(30)
pane.getChildren().add(btn)
print("pane =",pane)
print("btn =",pane.getChildren())
canvas = get_surface().get_native()
canvas.prefHeight(240)
print("canvas =",canvas)
pane.setVisible(True)
scene = javafx.scene.Scene(pane)
print("scene =",scene)
stage = canvas.getStage()
print("stage =",stage)
# stage.setScene(scene)
# stage.show()
def draw():
circle(100,200,50)
Error message:
Output: (attempt to put a JavaFX button in the window failed)
Addendum:
If we pause the thread right before stage.setScene() the button is shown but the circle is lost.
New Output:


