11-28-2009 02:26 AM - edited 11-28-2009 02:34 AM
Hi ll
can i get some example how to change the colour of the text that is displayed through rich textfield or lable Feild please help me ????
Now the text color by default it is in Black color but i want to display the text in White color
11-28-2009 10:08 AM
LabelField is easy - just override paint(), set the desired foreground color, and call super.paint()
RichTextField is more complicated. The colors for text are kept in an array, which corresponds to another array which locates the colored text region offset. This field is faily unusable "as is" - we had to create a wrapper that allows you to "addText" with a foreground color, background color, and font. It's a non-trivial effort, so use the LabelField if this works for you.
12-01-2009 02:09 AM
Supporting Rex explaination, give a look at this KB article.
If you ahve already solved the issue, you could mark it as solved, it will help other users to know the solution.
12-17-2010 09:16 AM - edited 12-17-2010 09:21 AM
super();
String str[] = new String[] {"Bob", "Bob2"};
int off[] = new int[] {0, str[0].length(), str[0].length() + str[1].length()};
byte attr[] = new byte[] {0, 1};
FontFamily fontfam[] = FontFamily.getFontFamilies();
Font fon[] = new Font[2];
fon[0] = fontfam[0].getFont(FontFamily.SCALABLE_FONT, 48);
fon[1] = fontfam[1].getFont(FontFamily.SCALABLE_FONT, 0);
add(new RichTextField(str[0] + str[1], off, attr, fon, RichTextField.TEXT_ALIGN_HCENTER));
String ramble = new String ("Ipsum Latinracka" +
add(new RichTextField(ramble, RichTextField.TEXT_ALIGN_HCENTER));
To get Bob, Bob2, and String ramble to appear in white, where in this coding would I insert this:
public void paint(Graphics graphics)
{
graphics.setColor(0x00008800);
super.paint(graphics);
}