### Access JavaFX API methods not exposed

In B4J not all JavaFX API methods are exposed.
To be able to access API methods that are not exposed, use JavaObject or Reflection.
To use JavaObject or Reflection ensure to include the libraries in the B4J IDE Libraries Manager.
The JavaFX documentation describes the API methods:
http://docs.oracle.com/javafx/2/api/index.html
The JavaObject is described here:
http://www.b4x.com/b4j/help/JavaObject.html
See also B4J HowTo category JavaObject > Access a Java Class.
Examples accessing an API method via a JavaObject
Button
'Define the button
Private btn As Button
'Assign the button to the JavaObject
Dim joBtn As JavaObject = btn
'The JavaObject acts as a button, means API methods can be used
'Reference: http://docs.oracle.com/javafx/2/api/javafx/scene/control/Button.html
joBtn.RunMethod("setText", Array As Object("About..."))
TextArea
' Define the textarea
Private TextArea1 As TextArea
'Assign the textarea control to the JavaObject
Dim joTA As JavaObject = TextArea1
'Use RunMethod to execute TextArea API methods
'Reference: http://docs.oracle.com/javase/8/docs/api/java/awt/TextArea.html
'Examples
'Set the text in the textarea
joTA.RunMethod("setText", Array As Object("Moin Moin"))
'Select all text in the textarea and replace the selected text by a new text
joTA.RunMethod("selectAll", Null)
joTA.RunMethod("replaceSelection", Array As Object("New Text"))
Form
'Sets a form to full screen
'Reference: http://docs.oracle.com/javase/8/javafx/api/javafx/stage/Stage.html
`Sub SetFullScreen(frm As Form)
'Create a new JavaObject and assign the form
Dim joForm As JavaObject = frm
'Get the stage field from the form
Dim joStage As JavaObject = joForm.GetField("stage")
'Apply the API method setFullScreen to the stage which is bind to the form
joStage.RunMethod("setFullScreen", Array(True))
End Sub`
Call Example
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
SetFullScreen(MainForm)
End Sub`
MQTT
Access to the API method isCleanSession
Class MqttConnectOptions
java.lang.Object
org.eclipse.paho.client.mqttv3.MqttConnectOptions
Add external library jMQTT.
Dim mqttco As MqttConnectOptions
mqttco.Initialize("","")
Dim joMQTT As JavaObject = mqttco
Log($"isCleanSession = ${joMQTT.RunMethod("isCleanSession",Null)}"$)
Output Example:
isCleanSession = true

Changed: , Category: JavaObject, File: T6C208M1519.htm, ID: 1519