0

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));
4
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by zawert
-1

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

you fucking tard ... gtfo the internet.

Votes + Comments
Do you think you're demonstrating some intelligence with this?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.