B4J Question Help right-aligning combo box items


Active Member
Licensed User
Hello everyone.
I'm having a really hard time making this work. I have a combo box and I need to align all of the entries to the right of the dropdown list. I've searched the forum and tried different things without luck:

1. Using CSSUtils:

CSSUtils.SetStyleProperty(CBOX_ProductType, "-fx-text-alignment", "right")
2. Applying the property directly:

CBOX_ProductType.Style = "-fx-text-alignment: right"
3. Adding the comboBox entires as individual labels

myLabel.Text = "SHOOT ME!"
myLabel.Alignment = "CENTER_RIGHT"
'It DOES change if I add the follwing line, but messes with the automatic comboBox width:
'myLabel.SetSize(CBOX_ProductType.PrefWidth, CBOX_ProductType.PrefHeight)
4. This solution DID work, but with a serious side-effect (which I shall mention) :

Dim myLabel As Label
Dim myPane As AnchorPane
myLabel.Text = "SHOOT ME!"
myLabel.Alignment = "CENTER_RIGHT"
myPane.AddNode(myLabel, 0, 0, -1, -1)
myPane.FillHorizontally(myLabel, 0, 10)

The problem with the last solution is that everything seems perfect at first, but once I click and select an item on the list, its text appears (as the chosen item) in white, hardly discernible! and even worse, the item's text disappears from the dropdown list (the space is there, but the word itself is gone).

I really need to make this work and it's driving me crazy! Any help is appreciated!
Thank you so much in advance.

P.S. I can't even make the text in a TextField aligned to the right. Please help me.
Last edited: