### Change ToolTip Style

To change the style of Tooltips:
Create in the Project Files Folder (DirAssets) a CSS file (like Main.css) with content:
.tooltip {
-fx-background-radius: 2 2 2 2;
-fx-background-color: linear-gradient(#FFFFFF, #DEDEDE);
-fx-text-fill: black;
-fx-font-size: 20px;
}
In B4J code set the MainForm style - this style applies to all controls:
MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Main.css"))
Note
The CSS file, in this case Main.css, can also include other settings.
Another option is to use API methods (requires the JavaObject library).
Example of changing the tooltip style of a button using API methods (Requires the JavaObject library).
Usage
Button_SetToolTipStyle(Button1, "-fx-font-size:20;-fx-background-color: linear-gradient(#FFFFFF, #DEDEDE); -fx-text-fill: orange;")
Button_SetToolTipStyle(Button2, "-fx-font-size:20;-fx-text-fill: yellow;")
Subroutine
`Private Sub Button_SetToolTipStyle(Btn As Button, Style As String)
Dim joButton As JavaObject = Btn
Dim ToolTipText As String = Btn.TooltipText
Dim joToolTip As JavaObject
joToolTip.InitializeNewInstance("javafx.scene.control.Tooltip", Array(ToolTipText))
joToolTip.RunMethod("setStyle", Array(Style))
joButton.RunMethod("setTooltip", Array(joToolTip))
End Sub`
Advanced Example
Set the tooltip style for buttons in a form, if the button tag is 1.
`Private Sub Form_SetButtonsTooltipStyle(frm As Form)
For Each n As Node In frm.RootPane.GetAllViewsRecursive
If n Is Button And n.Tag = "1" Then
Button_SetToolTipStyle(n, "-fx-font-size:20;-fx-background-color: linear-gradient(#FFFFFF, #DEDEDE); -fx-text-fill: black;")
End If
Next
End Sub`

Changed: 2018-05-01 17:33, Category: Tooltips, File: T6C271M2012.htm, ID: 2012