1

I want to display a text in button in codename-one application which having a 1 word in red and 1 word in Blue and rest are in black.

How can we do it.

Please help.

vikrant kumar
  • 208
  • 2
  • 14

1 Answers1

0

Labels in Codename One have one style/color and button derives from label hence it can't be done directly.

However, Codename One has a multi-button option which allows doing something very similar and it also allows placing elements into a single line. If the multi button doesn't suit your specific requirement you will need to use a lead component approach to construct your UI in a Container and assign the lead component (Container.setLeadComponent()) to a button within the Container. This effectively means the entire container will behave according to the "lead" of the button within the container hierarchy and you can assemble components to any look you want.

Alternatively you can derive button and override paint to do whatever you please.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65