Set font for different word inside a table field
Hi All, i've difficult to set text font for certain text inside a a table field. I've try to edit the highlight function to make it become set font function but it isn't work. Below is the highlight function in my code which work for text highlighter. I'm really appreaciated if have any help. Thank you very much.
function highglight:
--------------------
public void highlight(JTextComponent textComp, String pattern) {
// First remove all old highlights
removeHighlights(textComp);
try {
Highlighter hilite = textComp.getHighlighter();
Document doc = textComp.getDocument();
String text = doc.getText(0, doc.getLength());
int pos = 0;
// Search for pattern
while ((pos = text.indexOf(pattern, pos)) >= 0) {
// Create highlighter using private painter and apply around pattern
hilite.addHighlight(pos, pos+pattern.length(), myHighlightPainter);
pos += pattern.length();
}
} catch (BadLocationException e) {
}
}
|