### Sample #1 Hello World

Example of the classic HelloWorld Application.
The app runs in fully filled screen.
External libraries jPi4J, CSSUtils. These must be merged into the project.
MainForm Layout
Composed with the B4J Visual Designer using 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 = "v20180419"
Private CAPPTITLE As String = "B4J HowTo Raspberry Pi Liberica JDK10 - Hello World"
Private CAPPINFO As String = $"${CAPPVERSION} by Robert W.B. Linn"$
' 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.Show
AppInit
End Sub`
`Sub AppInit
' Labels
lblTitle.Text = CAPPTITLE
lblInfo.Text = $"${CAPPINFO} - Java ${GetSystemProperty("java.version","0.0.0_00")}"$
'Set the form to fill the screen with an offset - comment if want to use the window dimensions defined in the project attributes
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`
Region 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 Liberica, File: T6C287M2162.htm, ID: 2162