View Single Post
 
Old March 7th, 2006, 05:52 AM
android66 android66 is offline
Authorized User
 
Join Date: Oct 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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) {

        }
}