### Sample #1 Hello World

Example of the classic HelloWorld Application.
MainForm Layout
Created with the B4J Visual Designer, is composed out of following Views:
[Label (Title)][Button (X)]
[Label (Message]
[Label (Info)]
• Label (Anchors Horizontal Both, Vertical Top, Right Edge Distance 0) as Title
• Button with Close Image (Font Awesome X) Top Right (Anchors Horizontal Right, Vertical Top, Width 30)
• Label Message with font size 32
• Label (Anchors Horizontal Both, Vertical Bottom, Right Edge Distance 0) as Info
B4J Code Snippet
`Sub Process_Globals
Private CAPPVERSION As String = "v20170725"
Private CAPPTITLE As String = "B4J HowTo Raspberry Pi JavaFXPorts - HelloWorld"
Private CAPPINFO As String = $"${CAPPVERSION} created by Robert W.B. Linn, powered by B4J @ www.b4x.com "$
' Libs
Private fx As JFX
' Views
Private MainForm As Form
Private btnClose As Button
Private btnCloseX As Button
Private lblTitle As Label
Private lblMessage As Label
Private lblInfo As Label
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main")
MainForm.SetFormStyle("UTILITY")
MainForm.Resizable = False
MainForm.Show
AppInit
End Sub`
`Sub AppInit
' Labels
lblTitle.Text = CAPPTITLE
lblInfo.Text = CAPPINFO
'Set the form to fill the screen with an offset to ensure the cursor remains as default and not changing to a black square (probably a bug in javafxports)
SetFormFillScreenOffset(MainForm, 50)
' CSS
' Set the background color of the form to blue
CSSUtils.SetBackgroundColor(MainForm.RootPane, fx.Colors.LightGray)
End Sub`
`Sub AppClose
MainForm.Close
ExitApplication
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`
' Close the app using X Button top right corner
`Sub btnCloseX_Action
AppClose
End Sub`
' Close the app using close button bottom right
`Sub btnClose_Action
AppClose
End Sub`
' Helpers
' Returns the actual time using the datetime.timeformat set
`Sub IsNow As String 'ignore
Return DateTime.Time(DateTime.Now)
End Sub`
' Set the form to fill the screen with an offset
`Sub SetFormFillScreenOffset(frm As Form, offset As Int) 'ignore
Dim ps As Screen = fx.PrimaryScreen
frm.WindowLeft = ps.MinX + offset
frm.WindowWidth = ps.MaxX - frm.WindowLeft - offset
frm.WindowTop = ps.MinY + offset
frm.WindowHeight = ps.MaxY - frm.WindowTop - offset
End Sub`

Changed: 2018-06-07 09:22, Category: Raspberry Pi UI JavaFXPorts, File: T6C239M1752.htm, ID: 1752