Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim cm As ContextMenu
Dim jBeep As JavaObject
jBeep.InitializeStatic("java.awt.Toolkit")
jBeep = jBeep.RunMethod("getDefaultToolkit", Null)
Dim lb1 As Label
Dim jo As JavaObject
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
' MainForm.Resizable = False
' MainForm.SetFormStyle("UTILITY")
lb1.Initialize("")
MainForm.RootPane.AddNode(lb1, 100,300,300,100)
MainForm.Show
'create 2 separator instances
Dim smiClass As String = "javafx.scene.control.SeparatorMenuItem"
Dim smi() As Object = Array(jo.InitializeNewInstance(smiClass,Null), _
jo.InitializeNewInstance(smiClass,Null))
cm.Initialize("")
Dim mi As MenuItem '@MuuSer, Ok I admit it, your way is more clear, for now :-)
mi.Initialize("MenuItem1","MenuItem")
cm.MenuItems.Add(mi)
cm.MenuItems.Add(smi(0)) 'separator 1
Dim mi As MenuItem
mi.Initialize("MenuItem2","MenuItem")
cm.MenuItems.Add(mi)
cm.MenuItems.Add(smi(1)) 'separator 2
Dim mi As MenuItem
mi.Initialize("MenuItem3","MenuItem")
cm.MenuItems.Add(mi)
'install an Handler for onHidden event
'if needs can be changed with something else. see javafx ref.
Dim cmEventHandler As Object = jo.CreateEventFromUI("javafx.event.EventHandler", _
"ctxMenuOnHidden",False)
jo = cm
jo.RunMethod("setOnHidden", Array(cmEventHandler))
End Sub
Sub ctxMenuOnHidden_Event(MethodName As String, Args() As Object)As Object
Log("ContextMenu Hidden")
Beep
Return(True)
End Sub
Sub MainForm_MouseReleased(mData As MouseEvent)
jo = cm
If mData.SecondaryButtonPressed Then
jo.RunMethod("show", Array(MainForm.RootPane, _
MainForm.WindowLeft + MainForm.WindowWidth - MainForm.Width - 8 + mData.x, _
MainForm.WindowTop + MainForm.WindowHeight - MainForm.Height - 8 + mData.y))
Else
jo.RunMethod("hide",Null)
End If
End Sub
Sub MenuItem_Action
Dim Mitem As MenuItem = Sender
lb1.Text = Mitem.Text & " was fired"
Beep
End Sub
Sub Beep
jBeep.RunMethod("beep", Null)
End Sub