Sample to create a toolbar with [BUTTON][BUTTON][TEXTFIELD][LABEL][BUTTON]
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
'Define the toolbar JavaObject
Private joToolbar As JavaObject
Private tbButton1 As Button
Private tbButton2 As Button
Private tbTextField1 As TextField
Private tbLabel1 As Label
Private tbButton3 As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UTILITY")
MainForm.RootPane.LoadLayout("Main")
MainForm.Show
CreateToolBar
End Sub
'Handle resizing of the mainform which adjusts the width of the toolbar object
Sub MainForm_Resize (Width As Double, Height As Double)
joToolbar.RunMethod("setPrefWidth", Array(Width))
End Sub
Sub CreateToolBar
joToolbar.InitializeNewInstance("javafx.scene.control.ToolBar", Null)
tbButton1.Initialize("tbButton1"):tbButton1.Text="Button 1":tbButton1.TextColor=fx.Colors.Red
tbButton2.Initialize("tbButton2"):tbButton2.Text="Button 2":tbButton2.TextColor=fx.Colors.Blue
tbTextField1.Initialize("tbTextField1")
tbTextField1.TooltipText = "Enter text."
tbTextField1.PromptText = "Enter Text"
tbLabel1.Initialize("tbLabel1")
tbLabel1.Text = "Toolbar Label"
tbButton3.Initialize("tbButton3"):tbButton3.Text="About":tbButton3.TextColor=fx.Colors.Yellow
'Add the views to the toolbar
joToolbar.RunMethodJO("getItems", Null).runMethod("add", Array(tbButton1))
joToolbar.RunMethodJO("getItems", Null).runMethod("add", Array(tbButton2))
joToolbar.RunMethodJO("getItems", Null).runMethod("add", Array(tbTextField1))
joToolbar.RunMethodJO("getItems", Null).runMethod("add", Array(tbLabel1))
joToolbar.RunMethodJO("getItems", Null).runMethod("add", Array(tbButton3))
joToolbar.RunMethod("setStyle", Array("-fx-background-color: lightgrey;"))
'Add the toolbar
MainForm.RootPane.AddNode(joToolbar, 0, 0, MainForm.width, 50)
End Sub
Sub tbButton1_Action
Log("Toolbar Button1 clicked")
fx.Msgbox2(MainForm,"Toolbar Button 1 clicked", "Information", "OK", "", "", fx.MSGBOX_INFORMATION)
End Sub
Sub tbButton2_Action
Log("Toolbar Button2 clicked")
fx.Msgbox2(MainForm,"Toolbar Button 2 clicked", "Warning", "OK", "", "", fx.MSGBOX_WARNING)
End Sub
Sub tbButton3_Action
fx.Msgbox2(MainForm,MainForm.title, "About", "OK", "", "", fx.MSGBOX_INFORMATION)
End Sub