### Use JavaObject RunMethod

The JavaFX Controls have Methods defined which can be executed via JavaObject.RunMethod.
Information (fields, methods, etc.) about all JavaFX API classes:
http://docs.oracle.com/javafx/2/api/allclasses-noframe.html
Notes
• When using JavaObjects as local variables, memory will be released after the sub completes.
Simplification Parameter
NEW: JavaObject.RunMethod("some method", Array ("parameter 1", 2))
OLD: JavaObject.RunMethod("some method", Array As Object ("parameter 1", 2))
Example replace selection in a TextArea
To use the Class Method "replaceSelection" in a TextArea use a JavaObject with RunMethod.
The JavaFX TextArea has a method named "replaceSelection".
Reference: http://docs.oracle.com/javafx/2/api/javafx/scene/control/TextArea.html
Dim joTA As JavaObject = TextArea1
joTA.RunMethod("replaceSelection", Array("New Text"))
Hints
While defining, pressing CTRL Space behind the bracket lists those terms that might be inserted.
For a RunMethod, the IDE will not complete these strings as the IDE does not "know" them.
Example copy and paste clipboard using a TextArea
Copy and Paste from the clipboard can be done by using JavaFX control TextArea.
The TextArea control is wrapped to a JavaObject for which the Methods copy & paste are executed.
See http://docs.oracle.com/javafx/2/api/javafx/scene/control/TextInputControl.html
Note: There is a better way to use clipboard via the type Clipboard of the jFX library.
' CopyStringToClipboard via JavaObject
' Parameter: String
`Sub CopyStringToClipboard(s As String)
Dim ta As TextArea
ta.Initialize("ta")
ta.Text = s
ta.SelectAll
Dim jo As JavaObject = ta
jo.RunMethod("copy", Null)
End Sub`
' PasteStringFromClipboard via JavaObject
' Return: String
`Sub PasteStringFromClipboard As String
Dim ta As TextArea
ta.Initialize("ta")
Dim jo As JavaObject = ta
jo.RunMethod("paste", Null)
ta.SelectAll
Return ta.Text
End Sub`
Example Various
The output of the examples is shown in a listview (ID:listviewExamples)
`Sub JO_Example1
Dim jo As JavaObject
jo.InitializeStatic("java.awt.Toolkit")
Dim toolkit As JavaObject = jo.RunMethod("getDefaultToolkit", Null)
setOutput(listviewExamples.SelectedItem & CRLF & _
toolkit.RunMethod("getScreenSize", Null))
End Sub`
`Sub JO_Example2
Dim jo As JavaObject
Dim s As String = jo.InitializeStatic("java.awt.Toolkit").RunMethodJO("getDefaultToolkit", Null).RunMethod("getScreenResolution", Null)
setOutput(listviewExamples.SelectedItem & CRLF & s)
End Sub`
`Sub JO_Example3
Dim jo As JavaObject
jo.InitializeStatic("java.awt.Toolkit").RunMethodJO("getDefaultToolkit", Null).RunMethod("beep", Null)
setOutput(listviewExamples.SelectedItem)
End Sub`
`Sub JO_Example4
Dim jo As JavaObject
Dim s As String = jo.InitializeStatic("java.awt.Toolkit").RunMethodJO("getDefaultToolkit", Null).RunMethod("getColorModel", Null)
setOutput(listviewExamples.SelectedItem & CRLF & s)
End Sub`

Changed: , Category: JavaObject, File: T6C208M1530.htm, ID: 1530