Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
Dim poCan As Canvas
poCan.Initialize("")
MainForm.RootPane.AddNode(poCan, 0, 0, MainForm.Width, MainForm.Height)
MainForm.RootPane.Style = "-fx-background-color:#000000;"
Dim poFnt As Font = fx.CreateFont("Verdana", 25, False, False)
Dim psText As String = "This is a long line of text that should be wrapped due to the size limit applied."
Dim poImg As Image = WrapDrawnText(MainForm.RootPane, psText, fx.Colors.Blue, poFnt, "TOP_LEFT", 150dip)
poCan.DrawImage(poImg, 10dip, 10dip, poImg.Width, poImg.Height)
End Sub
Public Sub WrapDrawnText(Container As AnchorPane, Text As String, TextColor As Paint, TextFont As Font, TextAlign As String, MaxWidth As Int) As Image
Dim poImg As Image
Dim poLbl As Label
'Create a label
poLbl.Initialize("")
poLbl.WrapText = True
poLbl.Font = TextFont
poLbl.TextColor = TextColor
poLbl.Alignment = TextAlign
poLbl.Text = Text
poLbl.Style = "-fx-background-color: rgba(0, 0, 0, 0);"
Container.AddNode(poLbl, -MaxWidth, 0, MaxWidth, -1)
poImg = poLbl.Snapshot
poLbl.RemoveNodeFromParent
Return poImg
End Sub