Hello!
Just recently a customer told me that my app was... boring... that it lacked some images, so after crying out loud i remember that we can put icons but i still needed the text.
so... Ta Da!
This code will work for any node that has the Labeled inheritance and Text, for example:
Label, Button, checkbox, etc.
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Labeled.html
You can actually change where is the icon shown (righ, left, top, bottom) but i am not smart enough to do it without java
Just recently a customer told me that my app was... boring... that it lacked some images, so after crying out loud i remember that we can put icons but i still needed the text.
so... Ta Da!
B4X:
Utils.iconAndText(rolBtn0,0xF2BA,"Appoinment")
public Sub iconAndText(btn As Button,fontAwesome As String,text As String)
btn.Font = fx.CreateFontAwesome(35)
btn.Text = Chr(fontAwesome)
Dim lbl As Label
lbl.Initialize("")
lbl.Font = fx.CreateFont(fx.DefaultFont(16).FamilyName,16,True,False)
lbl.Text = text
lbl.TextSize = 16
Dim jBtn As JavaObject = btn
jBtn.RunMethod("setGraphic",Array(lbl))
End Sub
This code will work for any node that has the Labeled inheritance and Text, for example:
Label, Button, checkbox, etc.
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Labeled.html
You can actually change where is the icon shown (righ, left, top, bottom) but i am not smart enough to do it without java
B4X:
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
static public void setContentDisplayBottom (Button btn) {
btn.setContentDisplay(ContentDisplay.BOTTOM);
}
static public void setContentDisplayRight (Button btn) {
btn.setContentDisplay(ContentDisplay.RIGHT);
}