Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Change Color of StringItem

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Do you guys know of any method to change the color of the text in a StringItem
or any way to change the color of the text on the form it self thanks in advance

regards
Khai Huat
 
Tim Holloway
Bartender
Posts: 18465
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You won't be able to to it using println - that's not a screen output function!

Actual screen display controls posess properties that define their fonts, text color and other display attributes.
 
Syam Sathyan George
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Khai,

simple solution -

1,Make a CustomItem and override the paint() method.
2a,set the Graphics parameter of the paint method to desired color.
2b,print the any string into the Graphics parameter of the paint method.
3,Add this CustomItem to the Form.

TADA!!! and you see the String in Color inside the form.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!