i have a jtextpane now, i want that some text on it become bold, and not all
how can i possibly do this,
for exmple, i want to bold all the word "cool" found in my textpane..
i know that i should use a DocumentListener(Do I need??)
but i really want to know how to bold certain word found in my textpane, in this case
the word
"cool"
thanks for helping..
this is my code so far, and i dont know what to do
JTextPane JTP;
StyledDocument dsd=new DefaultStyledDocument();
SimpleAttributeSet a=new SimpleAttributeSet();
a.addAttribute(StyleConstants.CharacterConstants.Bold,Boolean.TRUE);
try
{
dsd.insertString(dsd.getLength(),"cool",a);
}
catch(Exception e)
{
}
JTP=new JTextPane(dsd);
getContentPane().add(new JScrollPane(JTP));