JavaFX Controls in py5

It’s possible to have controls in the JavaFX window control drawing in the Default FX2D window using standard Processing drawing calls. Note that size() parameters control the size of the default window and scene() parameters control the size of the JavaFX window.

# Uses Imported mode for py5
import javafx.stage.Stage

_wndW = 700
_wndH = 600

global pane

def settings():
  size(_wndW, _wndH, FX2D)
  
def setup():
  global slider
  global colorPicker
  
  window_title("Processing Drawing")
  stage = javafx.stage.Stage()
  stage.setTitle("JavaFX Controls")
  pane = javafx.scene.layout.Pane()
  
  # Slider
  slider = javafx.scene.control.Slider(1, 500, 75)
  slider.setLayoutX(60)
  slider.setLayoutY(20)
  pane.getChildren().add(slider)
  
  # ColorPicker
  colorPicker = javafx.scene.control.ColorPicker()
  colorPicker.setLayoutX(70)
  colorPicker.setLayoutY(80)
  colorPicker.setValue(javafx.scene.paint.Color.GREEN)
  pane.getChildren().add(colorPicker)
  
  scene = javafx.scene.Scene(pane, 300, 200)
  stage.setScene(scene)
  stage.show()

def draw():
  global slider
  global colorPicker
  
  background(209)
  Color = colorPicker.getValue()
  fill(int(Color.getRed()*255),int(Color.getGreen()*255),int(Color.getBlue()*255))
  circle(_wndW/2,_wndH/2, float(slider.getValue()))

Output: