943,915 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1542
  • Java RSS
Sep 13th, 2007
0

jtextpane help please..

Expand Post »
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
Java Syntax (Toggle Plain Text)
  1.  
  2. JTextPane JTP;
  3.  
  4. StyledDocument dsd=new DefaultStyledDocument();
  5.  
  6. SimpleAttributeSet a=new SimpleAttributeSet();
  7.  
  8. a.addAttribute(StyleConstants.CharacterConstants.Bold,Boolean.TRUE);
  9.  
  10.  
  11.  
  12. try
  13. {
  14. dsd.insertString(dsd.getLength(),"cool",a);
  15. }
  16. catch(Exception e)
  17. {
  18.  
  19. }
  20. JTP=new JTextPane(dsd);
  21.  
  22. getContentPane().add(new JScrollPane(JTP));
Similar Threads
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Sep 13th, 2007
0

Re: jtextpane help please..

Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Sep 14th, 2007
0

Re: jtextpane help please..

thanks for tht n=but i have got another better method..
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Sep 14th, 2007
0

Re: jtextpane help please..

Would be nice that you share it with others then...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Jan 30th, 2009
-1

Re: jtextpane help please..

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

you ****ing tard ... gtfo the internet.
Reputation Points: 7
Solved Threads: 0
Newbie Poster
zawert is offline Offline
1 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Convert String to an expression.
Next Thread in Java Forum Timeline: swt progressbar for foldercopy





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC