jtextpane help please..

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

jtextpane help please..

 
0
  #1
Sep 13th, 2007
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
  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));
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,511
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 522
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: jtextpane help please..

 
0
  #2
Sep 13th, 2007
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

Re: jtextpane help please..

 
0
  #3
Sep 14th, 2007
thanks for tht n=but i have got another better method..
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,267
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 493
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: jtextpane help please..

 
0
  #4
Sep 14th, 2007
Would be nice that you share it with others then...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1
Reputation: zawert is an unknown quantity at this point 
Solved Threads: 0
zawert zawert is offline Offline
Newbie Poster

Re: jtextpane help please..

 
-1
  #5
Jan 30th, 2009
Originally Posted by w32.sysfile View Post
thanks for tht n=but i have got another better method..

you ****ing tard ... gtfo the internet.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1141 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC