### Apply customized CSS

Example applying external CSS style to a button.
A default button to be customized with red background color, rotate by 5 degrees, increase size by 1.5
See comments in the project source.
The layout "main.bjl", created with the B4J Internal Designer, has 2 buttons.
`Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Button1 As Button
Private Button2 As Button
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
MainForm.SetFormStyle("UTILITY")
MainForm.Resizable = False
MainForm.Title = "B4J HowTo Customized Button"
MainForm.Show
' Create an external stylesheet CustomStyles.css in the project files folder
' .rotate-button {
' -fx-base: red;
' -fx-rotate: -5;
' -fx-scale-x: 1.5;
' -fx-scale-y: 1.5;
' }
'
' Add the external stylesheet to the files tab
' Add the external stylesheet to the mainform list of stylesheets
MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "CustomStyles.css"))
' Assign the customized style to the button1 - note: do not add the dot as defined in the external stylesheet
' Private Button1 As Button
Button1.StyleClasses.Add("rotate-button")
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`
`Sub Button1_Click
End Sub`
`Sub Button2_Click
End Sub`

Changed: 2018-06-05 13:19, Category: CSS, File: T6C177M2180.htm, ID: 2180