### Style Button

To style a button, lookup the Java FX Style reference (CSS) for a Button:
http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#button
The JavaFX API documentation:
http://docs.oracle.com/javafx/2/api/javafx/scene/control/Button.html
Note
It is recommended to style a button using the CSSUtils Library.Select CSSUtils in the B4J IDE Library Manager.
See B4J HowTo > Buttons > Style Button CSSUtils.
Define Button
`Sub Process_Globals
Private btnExample As Button
...
End Sub`
Some basic Button Style properties with example values:
Font and Font Size = -fx-font: 22 arial;
Font Color = -fx-text-fill: Blue;
Background Color = -fx-background-color: #FFFFFF;
Overrides the defaultcolor: = -fx-base: #b6e7c9;
Font Bold = -fx-font-weight: bold;
Font Style: -fx-font-style: [ normal | italic | oblique ] ;
Font Weight: -fx-font-weight: [ normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 ];
Example Button Hyperlink Style
' Style the button with white background and blue underlined text
btnExample.Style = "-fx-background-color: #FFFFFF; -fx-text-fill: blue; -fx-underline: true;"
Example Sub to set basic Button Style
' Set buttonstyle
' Parameter Background color (in Hex format, like #FFFFFF or direct as color name, like blue)
' Parameter Font color (in Hex format, like #FFFFFF or direct as color name, like blue)
' Parameter Font size as string, like 2.0em
' Example: button.Style = setButtonStyle("#FFFFFF", "Blue", "2.0em")
`Sub setButtonStyle(bgcolor As String, fontcolor As String, fontsize As String) As String
Return "-fx-background-color: " & bgcolor & "; -fx-text-fill: " & fontcolor & "; -fx-font-size: " & fontsize & ";"
End Sub`
Example setting Button Font
btnExample.Style = "-fx-font: 22 arial; -fx-base: #b6e7c9;"
The -fx-font property sets the font and a size for button.
The -fx-base property overrides the default color applied to the button.
As the result, button is light green with lager text size.
Example changing the color and text depending on style and text
`Sub btnExample_Action
If btnExample.Style = "-fx-background-color: red;" Then
btnExample.Style = "-fx-background-color: green;"
btnExample.Text = "Start"
Else
btnExample.Style = "-fx-background-color: red;"
btnExample.Text = "Stop"
End If
End Sub`
Example rounded Button
Add CSS Rule for a Rounded Button
.button {
-fx-background-radius: 10px;
}

Changed: , Category: Buttons, File: T6C167M1236.htm, ID: 1236