### Move Undecorated Form

To move a Form, by using the mouse, with an UNDECORATED Formstyle, define a JavaObject and run API method(s).
#Region Project Attributes
#MainFormWidth: 400
#MainFormHeight: 300
#End Region
`Sub Process_Globals
Private fx As JFX
Private MainForm As Form
'Define the X and Y position of the form as global
Private posXForm, posYForm As Double
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNDECORATED")
MainForm.Show
CSSUtils.SetStyleProperty(MainForm.RootPane, "-fx-background-color", "blue")
End Sub`
'if the mouse is pressed, store the X and Y pos in the globals
`Sub MainForm_MousePressed (EventData As MouseEvent)
posXForm = EventData.X
posYForm = EventData.Y
' Check if form to be closed by double mouse click
If EventData.ClickCount = 2 Then MainForm.Close
End Sub`
'If the mouse is dragged, set the global X and Y pos to the getScreenX or Y API methods
'Reference: https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/events/MouseEvent.html
`Sub MainForm_MouseDragged (EventData As MouseEvent)
Dim joEvent As JavaObject = EventData
MainForm.WindowLeft = joEvent.RunMethod("getScreenX", Null) - posXForm
MainForm.WindowTop = joEvent.RunMethod("getScreenY", Null) - posYForm
End Sub`

Changed: , Category: Forms, File: T6C195M1422.htm, ID: 1422