B4J Question Tabpanel - Change the Text Color?

GuyBooth

Active Member
Licensed User
Longtime User
Can I change the color of the title text of a tabpanel? I know I can change the tab background color … but my efforts with CSS to change the text color have yielded no success.
 

GuyBooth

Active Member
Licensed User
Longtime User
I'm having limited success with this …
Applying a css stylesheet like this changes the text on all the labels on my tabs:

B4X:
/* PiecesOnly Tabpane Tab title text Dark Green*/
 .tab .tab-label {
    -fx-text-fill: #05A005;
    -fx-font-weight: bold;
}
 .tab:selected .tab-label {
    -fx-text-fill: #05A005;
}

So far so good. Now I want to make each one different - so I use this code to ID the tab panes:
B4X:
    tpPiecesOnly.Id = "tpPiecesOnly"
    tpPrimaries.Id = "tpPrimaries"
    tpNowPlaying.Id = "tpNowPlaying"

and this in my css file:
B4X:
/* PiecesOnly Tabpane Tab title text Dark Green*/
#tpPiecesOnly .tab .tab-label {
    -fx-text-fill: #05A005;
    -fx-font-weight: bold;
}
#tpPiecesOnly .tab:selected .tab-label {
    -fx-text-fill: #05A005;
}
/* Primaries Tabpane Tab title text Dark Blue*/
#tpPrimaries .tab .tab-label {
    -fx-text-fill: #783CF0;
    -fx-font-weight: bold;
}
#tpPrimaries .tab:selected .tab-label {
    -fx-text-fill: #783CF0;
}
/* NowPlaying Tabpane Tab title text Orange*/
#tpNowPlaying .tab .tab-label {
    -fx-text-fill: #FFD700;
    -fx-font-weight: bold;
}
/*Tabpane Tab title text*/
#tpNowPlaying .tab:selected .tab-label {
    -fx-text-fill: #FFD700;
}

But nothing happens.
Any ideas?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
java_WaloRjQChq.png


B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private TabPane1 As TabPane
   Private xui As XUI
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   Dim richtext As B4JTextFlow
   richtext.Initialize
   CreateTab("2", richtext.Reset.Append("Red").SetColor(xui.Color_Red).CreateTextFlow)
   CreateTab("2", richtext.Reset.Append("Green").SetColor(0xFF006204).CreateTextFlow)
   CreateTab("2", richtext.Reset.Append("Blue").SetColor(xui.Color_Blue).CreateTextFlow)
End Sub

Sub CreateTab (LayoutFile As String, TextFlow As Pane)
   Dim t As TabPage = TabPane1.LoadLayout(LayoutFile, "")
   Dim jo As JavaObject = t
   jo.RunMethod("setGraphic", Array(TextFlow))
End Sub

Depends on XUI Views.
 
Upvote 0
Top