954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

jtextpane help please..

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));
w32.sysfile
Newbie Poster
14 posts since Aug 2007
Reputation Points: 9
Solved Threads: 0
 
Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

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

w32.sysfile
Newbie Poster
14 posts since Aug 2007
Reputation Points: 9
Solved Threads: 0
 

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

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
thanks for tht n=but i have got another better method..


you fucking tard ... gtfo the internet.

zawert
Newbie Poster
1 post since Jan 2009
Reputation Points: 7
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You