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));

thanks for tht n=but i have got another better method..

Would be nice that you share it with others then...

thanks for tht n=but i have got another better method..

you fucking tard ... gtfo the internet.

commented: Do you think you're demonstrating some intelligence with this? -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.