#Region Project Attributes
 #MainFormWidth: 600
 #MainFormHeight: 600
#End Region
Sub Process_Globals
 Private fx As JFX
 Private MainForm As Form
 Private TextArea1 As TextArea
 Private btnClearTextArea As Button
 Private btnAutoKeyPress As Button
 Private btnQuit As Button
 Dim keycodes As JavaObject
End Sub
Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 MainForm.RootPane.LoadLayout("1") 'Load the layout file.
 MainForm.Show
 keycodes.InitializeStatic("javafx.scene.input.KeyCode")
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
 Return True
End Sub
Sub btnClearTextArea_Click
 
 TextArea1.Text = ""
 TextArea1.RequestFocus
 
End Sub
Sub btnAutoKeyPress_Click
 
 AutoKeyPressCTRLV
 
End Sub
Sub btnQuit_Click
 
 ExitApplication
 
End Sub
Sub AutoKeyPressCTRLV
 Dim robot1 As JavaObject
 Dim jo1 As JavaObject
 
 jo1 = jo1.InitializeStatic("com.sun.glass.ui.Application")
 'robot1 = jo1.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
 robot1 = asJO(Me).RunMethod("newRobot",Array(asJO(MainForm.rootpane).RunMethodJO("getScene",Null)))
 TextArea1.RequestFocus
 
 robot1.RunMethod("keyPress", Array(keycodes.GetField("CONTROL")))
 robot1.RunMethod("keyPress", Array(keycodes.GetField("V")))
 robot1.RunMethod("keyRelease", Array(keycodes.GetField("V")))
 robot1.RunMethod("keyRelease", Array(keycodes.GetField("CONTROL")))
End Sub
Sub asJO(o As JavaObject) As JavaObject
 Return o
End Sub
#if java
import com.sun.javafx.robot.*;
import javafx.scene.Scene;
public static Object newRobot(Scene s){
 FXRobot robot = FXRobotFactory.createRobot(s);
 return robot;
}
#End If#Region Project Attributes
 #MainFormWidth: 600
 #MainFormHeight: 600
#End Region
Sub Process_Globals
 Private fx As JFX
 Private MainForm As Form
 Private ctrlV As JavaObject
 Dim ta As TextArea
 Dim b As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
 MainForm.Show
 ta.Initialize("")
 b.Initialize("paste")
 b.Text = "Paste"
 MainForm.RootPane.AddNode(ta,10,10,300,300)
 MainForm.RootPane.AddNode(b,10,350,100,20)
 ctrlV = asJO(Me).RunMethod("keyPressedEvent",Null)
 Log(ctrlV)
 ta.RequestFocus
 
End Sub
Sub asJO(o As JavaObject) As JavaObject
 Return o
End Sub
Sub paste_Click
 ctrlV.RunMethod("fireEvent",Array(ta,ctrlV))
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
 Return True
End Sub
#if java
import javafx.scene.input.*;
import javafx.event.Event;
public static KeyEvent keyPressedEvent(){
return new KeyEvent(KeyEvent.KEY_PRESSED,null,"V",KeyCode.V,false,true,false,false);
}
#End IfDaestrum the king and ThRuST the prince has left the building
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region
Sub Process_Globals
    
    Private fx As JFX
    Private MainForm As Form
    Private TextArea1 As TextArea
    Private Button1 As Button
    Private CTRL_V As JavaObject
    Private COMMAND_V As JavaObject
    
End Sub
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    
    
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
Sub Button1_Click
    
    TextArea1.RequestFocus
    
    CTRL_V = asJOKeyPressPaste(Me).RunMethod("keyPressedEventCTRL_V",Null)
    COMMAND_V = asJOKeyPressPaste(Me).RunMethod("keyPressedEventCOMMAND_V",Null)
    'Log(CTRL_V)
    
    AutoPaste_CTRL_V
    
End Sub
Sub asJOKeyPressPaste(o As JavaObject) As JavaObject
    Return o
End Sub
' PAY ATTENTION TO THIS LINE NULL WON'T WORK!!!
Sub AutoPaste_CTRL_V
    CTRL_V.RunMethod("fireEvent",Array(Null,CTRL_V))
End Sub
Sub AutoPaste_COMMAND_V
    COMMAND_V.RunMethod("fireEvent",Array(TextArea1,COMMAND_V))
End Sub
#if java
import javafx.scene.input.*;
import javafx.event.Event;
// CTRL_V (windows CTRL+V)
public static KeyEvent keyPressedEventCTRL_V()
{
    return new KeyEvent(KeyEvent.KEY_PRESSED,null,"V",KeyCode.V,false,true,false,false);
}
// COMMAND_V (Mac CMD+V)
public static KeyEvent keyPressedEventCOMMAND_V()
{
    return new KeyEvent(KeyEvent.KEY_PRESSED,null,"V",KeyCode.V,false,false,false,true);
}
// breaks down as
// KeyEvent(EventType<KeyEvent> eventType, String character, String text, KeyCode code, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown)
#End If