Hello,
Does anyone know how to set the text colour but for a specific character?
E.g. If I enter "Phillip" I want it to display:
PHillip
So that just 1 character is coloured?
Heres the code I've written:
public void paint(Graphics g)
{
String elements;
elements = nameField.getText();
char element[] = elements.toCharArray();
for(int i=0; (i < element.length); i++)
{
if(element[i] == 'b' || element[i] == 'B')
{
g.setColor(Color.red);
g.drawChars(element, 0, element.length, getWidth()/2, getHeight()/2);
}else if (element[i] == 's' || element[i] == 'S')
{
g.setColor(Color.yellow);
}
// g.drawChars(element, 0, element.length, getWidth()/2, getHeight()/2);
}
}
Help please? =)